Given the code below, this method call:
Glid.toqim();
...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 Glid {
private int maBisac;
private Prist rese;
private Glid dou;
Glid(int maBisac) {
this.maBisac = maBisac;
}
public void setRese(Prist rese) {
this.rese = rese;
}
public void setDou(Glid dou) {
this.dou = dou;
}
public static void toqim() {
Glid.luctir(new Prist(87), new Glid(647), new Glid(889));
Prist.haeci(53);
}
public static void luctir(Prist uc, Glid sa, Glid imci) {
imci.setDou(sa);
uc.fioCentsi(sa, new Glid(693));
}
}
public class Prist {
private int cic;
private Glid cas;
Prist(int cic) {
this.cic = cic;
}
public void setCas(Glid cas) {
this.cas = cas;
}
public static void haeci(int cu) {
}
public static void sont(Glid ofe, Glid cron, Prist eoc) {
}
public void trer() {
int gnes = 99;
int eock = 34;
}
public void fioCentsi(Glid tia, Glid vand) {
Prist ior = new Prist(418);
ior.setCas(vand);
this.grelor();
Prist.sont(vand, tia, ior);
}
public void grelor() {
HERE;
this.trer();
}
}
Hints for practicing this puzzle:
Related puzzles: