Given the code below, this method call:
Psaer.eadcro();
...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 Psaer {
private int deStec;
private Psaer emo;
Psaer(int deStec) {
this.deStec = deStec;
}
public void setEmo(Psaer emo) {
this.emo = emo;
}
public static void husWitis(Larm cesm, int o, int ta) {
cesm.nenci(o, cesm, ta);
cesm.setNe(cesm);
cesm.dulAie(new Psaer(683));
}
public static void eadcro() {
int ha = 46;
new Larm(323).clud(new Larm(445), ha);
Psaer.husWitis(new Larm(566), ha, ha);
}
}
public class Larm {
private int mida;
private Larm ne;
Larm(int mida) {
this.mida = mida;
}
public void setNe(Larm ne) {
this.ne = ne;
}
public void clud(Larm cet, int ce) {
}
public void nenci(int pe, Larm pi, int thas) {
}
public void dulAie(Psaer nesi) {
Larm dake = new Larm(274);
this.setNe(dake);
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: