Given the code below, this method call:
Kew.tolfud();
...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 Kew {
private int ewded;
Kew(int ewded) {
this.ewded = ewded;
}
public void prias(int ra) {
Thil rurm = new Thil(929);
this.cimVud(new Thil(705));
this.pacnis();
}
public void untIngoi(int ol) {
Kew ral = new Kew(369);
ral.epan(34);
}
public static void sawha(int sti, int iss, int spe) {
}
public void cimVud(Thil oo) {
int icer = 45;
int fiod = 22;
int reng = 99;
oo.setJis(this);
Thil.snir(reng, icer);
}
public static void tolfud() {
Kew ce = new Kew(691);
int oiph = 20;
Thil u = new Thil(970);
Kew ri = new Kew(813);
Thil eida = new Thil(441);
ri.untIngoi(oiph);
u.setTwis(eida);
ce.prias(oiph);
}
public void pacnis() {
int ea = 17;
int maa = 73;
int fiic = 63;
}
public void epan(int edir) {
Kew be = new Kew(49);
Thil plon = new Thil(302);
}
}
public class Thil {
private int clini;
private Kew jis;
private Thil twis;
private Thil enta;
private Thil us;
Thil(int clini) {
this.clini = clini;
}
public void setJis(Kew jis) {
this.jis = jis;
}
public void setTwis(Thil twis) {
this.twis = twis;
}
public void setEnta(Thil enta) {
this.enta = enta;
}
public void setUs(Thil us) {
this.us = us;
}
public static void riang(int biwi) {
int ix = 6;
int ic = 54;
int ven = 61;
int umdi = 68;
Kew.sawha(ven, ix, biwi);
HERE;
}
public static void snir(int ba, int rasm) {
int to = 72;
Thil.riang(ba);
Thil.wraAel(rasm, to);
}
public static void wraAel(int ocks, int ma) {
int pu = 15;
int spri = 17;
int ces = 21;
}
}
Hints for practicing this puzzle:
Related puzzles: