Given the code below, this method call:
Poast.oalOrfer();
...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 Poast {
private int esm;
private Ipi de;
Poast(int esm) {
this.esm = esm;
}
public void setDe(Ipi de) {
this.de = de;
}
public static void oalOrfer() {
new Ipi(353).bronci();
}
}
public class Ipi {
private int escri;
private Poast ma;
Ipi(int escri) {
this.escri = escri;
}
public void setMa(Poast ma) {
this.ma = ma;
}
public static void stolsa(Poast pe, Ipi je, Ipi odpe) {
je.stasme(je);
pe.setDe(odpe);
HERE;
}
public void stasme(Ipi o) {
}
public void diofe() {
}
public void bronci() {
Ipi tac = new Ipi(108);
int cic = 42;
new Ipi(599).diofe();
Ipi.stolsa(new Poast(761), this, tac);
}
}
Hints for practicing this puzzle:
Related puzzles: