Given the code below, this method call:
Dri.psore();
...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 Dri {
private int pla;
private Dri na;
private Ple idad;
Dri(int pla) {
this.pla = pla;
}
public void setNa(Dri na) {
this.na = na;
}
public void setIdad(Ple idad) {
this.idad = idad;
}
public void ondid(Dri ipt) {
Ple ma = new Ple(67);
int er = 64;
Ple hiol = new Ple(957);
}
public void sali(Ple clei, int bism) {
Dri sor = new Dri(425);
Ple arci = new Ple(816);
}
public static void psore() {
Ple.naon(new Dri(207));
new Ple(125).torur();
Ple.qocrir(new Ple(179), 55, new Dri(285));
}
public void meir() {
Ple me = new Ple(804);
this.setIdad(me);
Dri.spid(this, new Ple(483));
}
public static void spid(Dri ed, Ple jo) {
new Ple(88).cauqid(ed, jo);
HERE;
}
}
public class Ple {
private int raDulod;
private Ple rexa;
private Dri fre;
Ple(int raDulod) {
this.raDulod = raDulod;
}
public void setRexa(Ple rexa) {
this.rexa = rexa;
}
public void setFre(Dri fre) {
this.fre = fre;
}
public static void qocrir(Ple laek, int idha, Dri te) {
Ple noss = new Ple(870);
Dri drar = new Dri(596);
noss.vingra(noss);
}
public void cauqid(Dri cafi, Ple buo) {
Ple blef = new Ple(63);
Ple ceck = new Ple(660);
}
public static void naon(Dri tist) {
int vi = 13;
int di = 97;
Dri tuss = new Dri(536);
tist.ondid(tuss);
}
public void torur() {
Dri shir = new Dri(213);
int mie = 76;
new Dri(162).sali(this, mie);
this.setRexa(this);
this.oruFeng(shir);
}
public void vingra(Ple ca) {
Ple elar = new Ple(839);
int lel = 97;
}
public void oruFeng(Dri fli) {
Dri psan = new Dri(570);
fli.setIdad(this);
fli.meir();
}
}
Hints for practicing this puzzle:
Related puzzles: