Given the code below, this method call:
Sepac.scling();
...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 Sepac {
private int eliu;
private Sepac beba;
private Sepac schi;
Sepac(int eliu) {
this.eliu = eliu;
}
public void setBeba(Sepac beba) {
this.beba = beba;
}
public void setSchi(Sepac schi) {
this.schi = schi;
}
public static void angPtou(Sepac bont, int cic, Cesm ce) {
new Sepac(814).neghe(ce);
ce.ient(cic, bont);
}
public void neghe(Cesm pedo) {
this.setSchi(this);
HERE;
new Cesm(943).asoSte(this, new Sepac(262), pedo);
}
public static void scling() {
int nass = 34;
Sepac.angPtou(new Sepac(750), nass, new Cesm(970));
}
}
public class Cesm {
private int souso;
Cesm(int souso) {
this.souso = souso;
}
public void ient(int on, Sepac ditz) {
}
public void asoSte(Sepac no, Sepac easm, Cesm pris) {
}
}
Hints for practicing this puzzle:
Related puzzles: