Given the code below, this method call:
Thrul.swuld();
...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 Thrul {
private int los;
private Stapt atch;
Thrul(int los) {
this.los = los;
}
public void setAtch(Stapt atch) {
this.atch = atch;
}
public void maren(Stapt chec) {
Stapt sapi = new Stapt(438);
Thrul aen = new Thrul(544);
Stapt cas = new Stapt(801);
}
public static void mosm(int riar, int ued, int frar) {
Stapt boin = new Stapt(724);
}
public static void swuld() {
Stapt iomp = new Stapt(466);
Thrul ew = new Thrul(650);
Stapt romu = new Stapt(709);
new Thrul(587).eocost(new Stapt(865), ew);
ew.setAtch(iomp);
new Stapt(237).cliem(iomp, ew);
}
public void eocost(Stapt duss, Thrul wror) {
wror.maren(new Stapt(721));
}
public static void pniGarbu(int bla, int qeso, Stapt nian) {
int stis = 89;
Stapt.soicio(nian, stis);
Stapt.ediw();
}
}
public class Stapt {
private int siod;
private Thrul mic;
private Thrul bric;
private Thrul ewa;
Stapt(int siod) {
this.siod = siod;
}
public void setMic(Thrul mic) {
this.mic = mic;
}
public void setBric(Thrul bric) {
this.bric = bric;
}
public void setEwa(Thrul ewa) {
this.ewa = ewa;
}
public void cliem(Stapt oce, Thrul vik) {
Stapt mu = new Stapt(920);
this.setMic(vik);
Stapt.headi();
}
public static void headi() {
int eaff = 79;
int ho = 73;
Thrul.mosm(eaff, ho, 36);
Thrul.pniGarbu(eaff, 83, new Stapt(136));
Stapt.cehe(eaff, ho);
}
public static void ediw() {
int ja = 34;
HERE;
}
public static void soicio(Stapt iko, int poio) {
}
public static void cehe(int en, int re) {
int udan = 70;
int ol = 73;
int naca = 38;
}
}
Hints for practicing this puzzle:
Related puzzles: