Given the code below, this method call:
Stuse.cedod();
...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 Stuse {
private int inHeda;
private Stuse phoe;
private Stuse opsa;
Stuse(int inHeda) {
this.inHeda = inHeda;
}
public void setPhoe(Stuse phoe) {
this.phoe = phoe;
}
public void setOpsa(Stuse opsa) {
this.opsa = opsa;
}
public static void cedod() {
Stuse.iorb();
new Stuse(91).prui(new Tir(656), new Stuse(683));
}
public static void iorb() {
int sqo = 3;
Tir oc = new Tir(449);
Stuse pri = new Stuse(823);
pri.setOpsa(pri);
oc.wess(oc, sqo, new Tir(334));
}
public void prui(Tir arbi, Stuse al) {
}
}
public class Tir {
private int cinia;
Tir(int cinia) {
this.cinia = cinia;
}
public void wess(Tir gock, int cral, Tir clal) {
HERE;
this.leckie();
}
public void leckie() {
Tir zong = new Tir(928);
Tir lu = new Tir(663);
}
}
Hints for practicing this puzzle:
Related puzzles: