Given the code below, this method call:
Pring.cusspi();
...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 Pring {
private int inMi;
private Tru io;
Pring(int inMi) {
this.inMi = inMi;
}
public void setIo(Tru io) {
this.io = io;
}
public static void cusspi() {
Tru lerd = new Tru(93);
Pring o = new Pring(10);
o.setIo(lerd);
new Tru(926).trepsi();
}
}
public class Tru {
private int croun;
Tru(int croun) {
this.croun = croun;
}
public void prai(int hik, Tru dru, int un) {
}
public void trepsi() {
int tios = 2;
HERE;
this.prai(tios, this, tios);
}
}
Hints for practicing this puzzle:
Related puzzles: