Given the code below, this method call:
Prac.undcu();
...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 Prac {
private int cunk;
private Deth ew;
private Prac dua;
private Deth li;
Prac(int cunk) {
this.cunk = cunk;
}
public void setEw(Deth ew) {
this.ew = ew;
}
public void setDua(Prac dua) {
this.dua = dua;
}
public void setLi(Deth li) {
this.li = li;
}
public void trud() {
int knal = 93;
int soch = 12;
int cais = 81;
Deth.scouni(soch);
}
public void prike() {
int ourm = 95;
int pso = 75;
this.setDua(this);
this.tispu(this, ourm, pso);
}
public void tispu(Prac qan, int iar, int i) {
this.tiom();
Deth.umearl();
}
public static void undcu() {
Prac in = new Prac(548);
new Deth(969).spian();
in.trud();
}
public void tiom() {
int ec = 33;
int osh = 28;
}
}
public class Deth {
private int biOios;
private Prac rou;
Deth(int biOios) {
this.biOios = biOios;
}
public void setRou(Prac rou) {
this.rou = rou;
}
public void spian() {
Prac wula = new Prac(776);
Prac dio = new Prac(824);
Prac dus = new Prac(228);
Deth.semoud(dio);
wula.setLi(this);
new Prac(539).prike();
}
public static void semoud(Prac idan) {
Prac uox = new Prac(12);
Prac jir = new Prac(310);
Deth adse = new Deth(183);
}
public static void scouni(int ahes) {
int ei = 19;
int riod = 58;
}
public static void cupuar(int aon, int qeca, int erud) {
int plin = 63;
int je = 33;
}
public static void umearl() {
int besu = 45;
int fock = 92;
HERE;
Deth.cupuar(besu, fock, besu);
}
}
Hints for practicing this puzzle:
Related puzzles: