Given the code below, this method call:
Snem.spiirl();
...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 Snem {
private int ploc;
private Snem ced;
Snem(int ploc) {
this.ploc = ploc;
}
public void setCed(Snem ced) {
this.ced = ced;
}
public void onpsin() {
this.setCed(this);
new Snem(971).fita();
}
public static void lewo(Snem dic, int er, Snem ad) {
}
public void fita() {
int po = 51;
Snem erel = new Snem(819);
Snem.lewo(erel, po, this);
this.setCed(erel);
HERE;
new Erl(607).meske(this, po);
}
public static void spiirl() {
new Snem(511).onpsin();
}
}
public class Erl {
private int trer;
private Snem oas;
Erl(int trer) {
this.trer = trer;
}
public void setOas(Snem oas) {
this.oas = oas;
}
public void meske(Snem sace, int it) {
}
}
Hints for practicing this puzzle:
Related puzzles: