Given the code below, this method call:
Scin.spasme();
...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 Scin {
private int edem;
Scin(int edem) {
this.edem = edem;
}
public void padmua() {
this.niic();
new Scin(3).praUphe(this);
}
public static void spasme() {
int be = 39;
Noiss heun = new Noiss(865);
Scin esbe = new Scin(841);
heun.setBa(esbe);
esbe.padmua();
}
public void praUphe(Scin elo) {
}
public void niic() {
Noiss ho = new Noiss(814);
new Scin(937).laldni(new Noiss(539), this);
ho.setBa(this);
HERE;
}
public void laldni(Noiss eae, Scin tasa) {
}
}
public class Noiss {
private int saAep;
private Scin stea;
private Scin ba;
Noiss(int saAep) {
this.saAep = saAep;
}
public void setStea(Scin stea) {
this.stea = stea;
}
public void setBa(Scin ba) {
this.ba = ba;
}
}
Hints for practicing this puzzle:
Related puzzles: