Given the code below, this method call:
Gaft.twisa();
...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 Gaft {
private int gonga;
private Gaft sa;
Gaft(int gonga) {
this.gonga = gonga;
}
public void setSa(Gaft sa) {
this.sa = sa;
}
public static void twisa() {
new Gaft(942).iliIsco(new Thal(630), new Thal(620), new Gaft(711));
}
public void iliIsco(Thal poul, Thal bi, Gaft pe) {
poul.choni(this);
this.setSa(pe);
HERE;
}
}
public class Thal {
private int seCosun;
Thal(int seCosun) {
this.seCosun = seCosun;
}
public void choni(Gaft fres) {
}
}
Hints for practicing this puzzle:
Related puzzles: