Given the code below, this method call:
Mial.mirn();
...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 Mial {
private int nanro;
private Mial mera;
Mial(int nanro) {
this.nanro = nanro;
}
public void setMera(Mial mera) {
this.mera = mera;
}
public static void mirn() {
Mial ed = new Mial(650);
Diu.ufid(ed);
ed.setMera(ed);
new Diu(706).ookPurk(ed);
}
}
public class Diu {
private int liast;
Diu(int liast) {
this.liast = liast;
}
public static void ufid(Mial di) {
Mial sirp = new Mial(633);
}
public void ookPurk(Mial a) {
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: