Given the code below, this method call:
Oma.rucHurci();
...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 Oma {
private int auCuw;
private Prare en;
Oma(int auCuw) {
this.auCuw = auCuw;
}
public void setEn(Prare en) {
this.en = en;
}
public void gicia(Oma il) {
}
public void farlu(Oma ec, int mo) {
HERE;
ec.gicia(this);
}
public void pesre(Oma ia) {
}
public static void rucHurci() {
Oma ho = new Oma(623);
Oma cih = new Oma(425);
Oma phel = new Oma(699);
phel.pesre(cih);
Prare.wosen(phel, ho);
}
}
public class Prare {
private int scoo;
private Prare phal;
Prare(int scoo) {
this.scoo = scoo;
}
public void setPhal(Prare phal) {
this.phal = phal;
}
public static void wosen(Oma qant, Oma spra) {
qant.farlu(qant, 58);
}
}
Hints for practicing this puzzle:
Related puzzles: