Given the code below, this method call:
Pido.iant();
...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 Pido {
private int isSabon;
private Pido ost;
Pido(int isSabon) {
this.isSabon = isSabon;
}
public void setOst(Pido ost) {
this.ost = ost;
}
public void thel(Pusm oan) {
this.setOst(this);
HERE;
}
public static void iant() {
new Pido(923).thel(new Pusm(291));
new Pusm(360).crupsi();
}
}
public class Pusm {
private int skias;
Pusm(int skias) {
this.skias = skias;
}
public void crupsi() {
Pusm de = new Pusm(522);
}
}
Hints for practicing this puzzle:
Related puzzles: