Given the code below, this method call:
Stres.ebrais();
...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 Stres {
private int boscu;
private Iop nec;
private Stres vi;
private Iop am;
Stres(int boscu) {
this.boscu = boscu;
}
public void setNec(Iop nec) {
this.nec = nec;
}
public void setVi(Stres vi) {
this.vi = vi;
}
public void setAm(Iop am) {
this.am = am;
}
public static void ossan(Iop oun, int qan, int co) {
int um = 62;
}
public static void pidsod(int trem, Iop al, int chu) {
int paje = 11;
}
public static void ebrais() {
new Iop(986).gesiss(new Stres(757), new Stres(847), new Stres(416));
}
public static void arao() {
int iden = 94;
int adro = 43;
int frou = 78;
}
}
public class Iop {
private int jolic;
private Iop fos;
Iop(int jolic) {
this.jolic = jolic;
}
public void setFos(Iop fos) {
this.fos = fos;
}
public void zagh(int neae, int onec) {
int ce = 74;
this.prenas(ce);
HERE;
Stres.pidsod(neae, this, onec);
}
public void ounen(int gran) {
int ma = 30;
Stres.ossan(this, gran, ma);
this.setFos(this);
this.zagh(gran, ma);
}
public void prenas(int ja) {
}
public void fahi(Iop nism, Stres cu) {
int prun = 37;
int he = 14;
Stres.arao();
nism.setFos(this);
nism.ounen(50);
}
public void gesiss(Stres noie, Stres sesm, Stres hasm) {
noie.setVi(sesm);
new Iop(504).fahi(new Iop(708), sesm);
}
}
Hints for practicing this puzzle:
Related puzzles: