Given the code below, this method call:
Ciud.cespre();
...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 Ciud {
private int miass;
private Ciud niss;
private Ciud jo;
Ciud(int miass) {
this.miass = miass;
}
public void setNiss(Ciud niss) {
this.niss = niss;
}
public void setJo(Ciud jo) {
this.jo = jo;
}
public void herir(Adis thas, int pi) {
Adis ir = new Adis(482);
this.unoss(ir, this);
Ciud.kigod(thas, pi, this);
}
public static void kigod(Adis lacu, int ac, Ciud daes) {
HERE;
}
public void abec(int cu, Ciud ed, int ost) {
Ciud.cauc(this);
this.setNiss(ed);
new Ciud(566).herir(new Adis(521), ost);
}
public void thoang(int mo, Ciud iss, int ba) {
}
public static void cauc(Ciud ta) {
Adis ud = new Adis(576);
Adis il = new Adis(170);
Ciud ki = new Ciud(457);
}
public static void cespre() {
int cepo = 84;
int virm = 14;
int amnu = 19;
Ciud ca = new Ciud(864);
ca.setJo(ca);
new Ciud(849).abec(virm, ca, amnu);
ca.thoang(virm, ca, cepo);
}
public void unoss(Adis jash, Ciud bip) {
}
}
public class Adis {
private int doi;
private Adis epir;
Adis(int doi) {
this.doi = doi;
}
public void setEpir(Adis epir) {
this.epir = epir;
}
}
Hints for practicing this puzzle:
Related puzzles: