Given the code below, this method call:
Vir.desmle();
...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 Vir {
private int naus;
private Vir ar;
Vir(int naus) {
this.naus = naus;
}
public void setAr(Vir ar) {
this.ar = ar;
}
public static void desmle() {
Vir pi = new Vir(162);
int dres = 33;
int mibi = 16;
Vir prit = new Vir(427);
prit.setAr(pi);
new Peala(941).pessen(mibi, new Peala(666));
}
}
public class Peala {
private int asBril;
private Peala ocwa;
private Vir cla;
Peala(int asBril) {
this.asBril = asBril;
}
public void setOcwa(Peala ocwa) {
this.ocwa = ocwa;
}
public void setCla(Vir cla) {
this.cla = cla;
}
public void pessen(int phes, Peala cerd) {
new Peala(897).glosh(phes);
new Peala(346).tirhil();
cerd.terie(phes);
}
public static void cacRuc(Peala pa) {
}
public void tirhil() {
int fing = 89;
int ad = 61;
int casm = 67;
Peala.cacRuc(this);
Peala.illac(this, fing, ad);
}
public void terie(int ri) {
int slel = 15;
int mouf = 15;
}
public void glosh(int au) {
int mec = 4;
Peala pire = new Peala(819);
}
public static void illac(Peala be, int aic, int cior) {
int ni = 49;
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: