Given the code below, this method call:
Cec.litie();
...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 Cec {
private int moIcis;
private Cec moma;
Cec(int moIcis) {
this.moIcis = moIcis;
}
public void setMoma(Cec moma) {
this.moma = moma;
}
public static void litie() {
int ci = 65;
new Cec(129).lesh();
Pecma.serpse(ci, ci, ci);
}
public void lesh() {
Cec e = new Cec(934);
int pren = 5;
this.setMoma(e);
Pecma.foso();
}
}
public class Pecma {
private int pao;
private Pecma no;
Pecma(int pao) {
this.pao = pao;
}
public void setNo(Pecma no) {
this.no = no;
}
public static void serpse(int cesh, int regs, int pe) {
}
public void liri(Pecma i, Pecma gaho, Pecma pa) {
}
public static void foso() {
Pecma rak = new Pecma(772);
Pecma izir = new Pecma(230);
izir.setNo(rak);
HERE;
izir.liri(izir, rak, rak);
}
}
Hints for practicing this puzzle:
Related puzzles: