Given the code below, this method call:
Frus.steWep();
...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 Frus {
private int siRa;
private Frus osu;
Frus(int siRa) {
this.siRa = siRa;
}
public void setOsu(Frus osu) {
this.osu = osu;
}
public static void trel() {
Frus be = new Frus(36);
int enca = 34;
be.setOsu(be);
Etrar.lilAnsban(enca, be, new Frus(783));
Etrar.cinProur(be, new Etrar(419));
}
public void sceWui(Frus greu, int id, int ci) {
}
public static void steWep() {
int ract = 77;
Frus sest = new Frus(958);
int cior = 7;
sest.setOsu(sest);
Frus.trel();
sest.sceWui(sest, ract, cior);
}
}
public class Etrar {
private int mepve;
private Frus es;
Etrar(int mepve) {
this.mepve = mepve;
}
public void setEs(Frus es) {
this.es = es;
}
public static void lilAnsban(int me, Frus esna, Frus suct) {
HERE;
}
public static void cinProur(Frus ceol, Etrar soal) {
int giis = 53;
}
}
Hints for practicing this puzzle:
Related puzzles: