Given the code below, this method call:
Ris.paac();
...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 Ris {
private int aci;
Ris(int aci) {
this.aci = aci;
}
public static void paac() {
int trea = 40;
new Ris(407).sothap(trea, new Hedi(171), trea);
}
public void sothap(int ed, Hedi vech, int adra) {
vech.setSiem(this);
HERE;
new Hedi(399).groa(vech);
}
}
public class Hedi {
private int fri;
private Ris siem;
Hedi(int fri) {
this.fri = fri;
}
public void setSiem(Ris siem) {
this.siem = siem;
}
public void groa(Hedi uco) {
}
}
Hints for practicing this puzzle:
Related puzzles: