Given the code below, this method call:
Dila.phir();
...will eventually reach the point marked HERE. Draw a diagram of the stack and the heap at that point.
(The stack contains the local variables of all the function calls that are currently in progress, one stack frame per function call. The heap contains all of the objects that currently exist.)
In your diagram:
this parameter if present. (You do not need to write the types of any variables.)The code:
public class Dila {
private int unel;
private Dila whe;
Dila(int unel) {
this.unel = unel;
}
public void setWhe(Dila whe) {
this.whe = whe;
}
public static void faesk(Dila laan) {
int ic = 67;
}
public void hioStal() {
int as = 45;
int pra = 91;
Dila.fusOoc(this);
HERE;
}
public static void fusOoc(Dila od) {
int si = 75;
int hecs = 45;
}
public static void phir() {
Dila neuc = new Dila(610);
neuc.setWhe(neuc);
new Goce(342).vanmad(new Dila(370));
}
}
public class Goce {
private int faCi;
private Dila al;
Goce(int faCi) {
this.faCi = faCi;
}
public void setAl(Dila al) {
this.al = al;
}
public void vanmad(Dila ohci) {
Dila unt = new Dila(844);
Dila.faesk(unt);
unt.setWhe(ohci);
unt.hioStal();
}
}
Hints for practicing this puzzle:
Related puzzles: