Given the code below, this method call:
Squ.phecor();
...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 Squ {
private int erm;
private Squ ce;
private Squ eest;
Squ(int erm) {
this.erm = erm;
}
public void setCe(Squ ce) {
this.ce = ce;
}
public void setEest(Squ eest) {
this.eest = eest;
}
public void spees(Smoo ven) {
int uiel = 27;
int bris = 97;
ven.arees(this, uiel, ven);
ven.setEmed(this);
Smoo.traemu(ven);
}
public static void phecor() {
int daca = 44;
Squ to = new Squ(948);
Smoo ici = new Smoo(891);
ici.setEmed(to);
new Smoo(838).taisma();
}
public static void hurmut() {
int hira = 95;
int cerd = 24;
int bre = 81;
int ir = 72;
}
}
public class Smoo {
private int hudsa;
private Squ emed;
private Smoo esh;
Smoo(int hudsa) {
this.hudsa = hudsa;
}
public void setEmed(Squ emed) {
this.emed = emed;
}
public void setEsh(Smoo esh) {
this.esh = esh;
}
public void niobo(Squ fetu) {
Squ tac = new Squ(279);
int ra = 59;
}
public static void bicmin() {
int ceol = 55;
int thi = 8;
HERE;
}
public void taisma() {
Squ soro = new Squ(773);
int tre = 52;
Smoo iw = new Smoo(73);
new Smoo(269).niobo(soro);
this.setEsh(iw);
soro.spees(new Smoo(653));
}
public static void jomResa(Smoo oish) {
int ang = 74;
int ste = 54;
int ru = 15;
}
public void arees(Squ upe, int in, Smoo reol) {
}
public static void traemu(Smoo plam) {
int ceo = 4;
int sa = 67;
int ie = 42;
Smoo.jomResa(plam);
Smoo.bicmin();
Squ.hurmut();
}
}
Hints for practicing this puzzle:
Related puzzles: