Given the code below, this method call:
Ospri.indesm();
...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 Ospri {
private int preff;
private Pasm ad;
Ospri(int preff) {
this.preff = preff;
}
public void setAd(Pasm ad) {
this.ad = ad;
}
public static void indesm() {
Pasm ul = new Pasm(29);
Ospri.ubre(ul, new Ospri(276), new Pasm(521));
}
public static void ubre(Pasm tru, Ospri hisu, Pasm li) {
hisu.setAd(li);
HERE;
hisu.woleun(hisu);
}
public void woleun(Ospri siac) {
}
}
public class Pasm {
private int cas;
Pasm(int cas) {
this.cas = cas;
}
}
Hints for practicing this puzzle:
Related puzzles: