Given the code below, this method call:
Doall.upnin();
...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 Doall {
private int emeng;
private Apral mur;
private Doall kaer;
Doall(int emeng) {
this.emeng = emeng;
}
public void setMur(Apral mur) {
this.mur = mur;
}
public void setKaer(Doall kaer) {
this.kaer = kaer;
}
public static void salpe() {
int dima = 7;
}
public static void upnin() {
Apral os = new Apral(252);
Apral a = new Apral(916);
Apral olis = new Apral(646);
a.botes(new Apral(791), a);
olis.crun(a, 95);
}
}
public class Apral {
private int ivis;
Apral(int ivis) {
this.ivis = ivis;
}
public void botes(Apral io, Apral niss) {
}
public void crun(Apral i, int or) {
new Apral(961).spasil(60, i);
Doall.salpe();
}
public void spasil(int fia, Apral ni) {
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: