Given the code below, this method call:
Poceb.jisSetbi();
...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 Poceb {
private int bacna;
Poceb(int bacna) {
this.bacna = bacna;
}
public void rhad(Diw ku) {
HERE;
}
public static void jisSetbi() {
Diw lu = new Diw(178);
new Poceb(596).rhad(new Diw(397));
lu.mihu(lu, lu, lu);
}
}
public class Diw {
private int undhe;
private Poceb pril;
Diw(int undhe) {
this.undhe = undhe;
}
public void setPril(Poceb pril) {
this.pril = pril;
}
public void mihu(Diw gino, Diw si, Diw be) {
}
}
Hints for practicing this puzzle:
Related puzzles: