Given the code below, this method call:
Atoid.atsIor();
...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 Atoid {
private int ketus;
private Rhes sest;
Atoid(int ketus) {
this.ketus = ketus;
}
public void setSest(Rhes sest) {
this.sest = sest;
}
public static void atsIor() {
new Rhes(562).irdpa(new Atoid(676));
new Rhes(946).kipne(new Rhes(257), new Rhes(357));
}
}
public class Rhes {
private int terve;
Rhes(int terve) {
this.terve = terve;
}
public void irdpa(Atoid seng) {
seng.setSest(this);
HERE;
}
public void kipne(Rhes tril, Rhes pruw) {
}
}
Hints for practicing this puzzle:
Related puzzles: