Given the code below, this method call:
Herge.kengo();
...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 Herge {
private int snor;
private Rhile toti;
private Herge il;
Herge(int snor) {
this.snor = snor;
}
public void setToti(Rhile toti) {
this.toti = toti;
}
public void setIl(Herge il) {
this.il = il;
}
public static void camia(int osod, Rhile ong, Herge idru) {
Rhile ge = new Rhile(85);
}
public void boin(Rhile cesm, int re) {
int juc = 24;
Herge.poun(this);
this.setToti(cesm);
HERE;
}
public static void kengo() {
int sce = 58;
Herge ang = new Herge(899);
new Rhile(232).bopu(new Rhile(316), ang, sce);
}
public static void poun(Herge lu) {
int og = 94;
int clud = 61;
int ced = 1;
int und = 59;
}
public static void mengbo() {
int spes = 23;
int peo = 60;
int dohi = 12;
int ches = 35;
int mi = 86;
}
}
public class Rhile {
private int stome;
private Herge ibim;
private Herge mep;
Rhile(int stome) {
this.stome = stome;
}
public void setIbim(Herge ibim) {
this.ibim = ibim;
}
public void setMep(Herge mep) {
this.mep = mep;
}
public void ulpial(Rhile spi, int bips) {
int ua = 4;
int tesm = 13;
}
public void anha(int us) {
Herge.camia(us, this, new Herge(814));
new Rhile(36).radod(us);
Herge.mengbo();
}
public void bopu(Rhile erap, Herge ta, int u) {
ta.setToti(this);
this.anha(u);
}
public void radod(int igan) {
new Herge(31).boin(new Rhile(46), igan);
this.ulpial(this, igan);
}
}
Hints for practicing this puzzle:
Related puzzles: