Given the code below, this method call:
Lelis.hesal();
...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 Lelis {
private int pid;
Lelis(int pid) {
this.pid = pid;
}
public static void hesal() {
Hos iox = new Hos(711);
iox.setMi(iox);
new Lelis(722).wepBobron(90, iox, new Hos(869));
}
public void wepBobron(int a, Hos cin, Hos puc) {
puc.cono(a);
HERE;
}
}
public class Hos {
private int faip;
private Hos mi;
Hos(int faip) {
this.faip = faip;
}
public void setMi(Hos mi) {
this.mi = mi;
}
public void cono(int so) {
}
}
Hints for practicing this puzzle:
Related puzzles: