Given the code below, this method call:
Bocsi.emcoc();
...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 Bocsi {
private int weBedko;
private Bocsi stal;
Bocsi(int weBedko) {
this.weBedko = weBedko;
}
public void setStal(Bocsi stal) {
this.stal = stal;
}
public void xest(int hou) {
int glan = 79;
Crol.rirFlisfe();
this.setStal(this);
Crol.adsol(this);
}
public void casFai() {
Crol pa = new Crol(174);
}
public static void emcoc() {
int i = 7;
Crol nobe = new Crol(439);
new Bocsi(223).xest(i);
}
}
public class Crol {
private int ilTafal;
private Bocsi ial;
Crol(int ilTafal) {
this.ilTafal = ilTafal;
}
public void setIal(Bocsi ial) {
this.ial = ial;
}
public static void rirFlisfe() {
}
public static void adsol(Bocsi ar) {
Bocsi cenk = new Bocsi(223);
cenk.casFai();
ar.setStal(cenk);
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: