Given the code below, this method call:
Cama.sanges();
...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 Cama {
private int inOior;
private Cama stis;
private Dimis niow;
Cama(int inOior) {
this.inOior = inOior;
}
public void setStis(Cama stis) {
this.stis = stis;
}
public void setNiow(Dimis niow) {
this.niow = niow;
}
public static void aelBauith(Cama ced) {
int oc = 56;
int ac = 41;
int cio = 74;
int glul = 25;
Cama.ganeal();
Cama.poesm();
}
public static void sanges() {
new Cama(655).angsca(new Dimis(311), new Dimis(928));
}
public static void ganeal() {
int eum = 58;
int aen = 9;
Dimis.siuMeex();
HERE;
Cama.praph();
}
public static void ucsOdsto(Cama gurp, Cama tro, Dimis wa) {
tro.setStis(gurp);
Cama.aelBauith(tro);
}
public static void praph() {
int miw = 87;
int cil = 21;
int er = 30;
int tac = 13;
}
public static void cata(Dimis oll, Cama itha) {
int tul = 21;
int oss = 43;
int je = 2;
}
public static void poesm() {
int thim = 73;
int pe = 41;
int rogs = 49;
int me = 79;
int beir = 21;
}
public void angsca(Dimis ca, Dimis fe) {
Cama har = new Cama(874);
Cama eser = new Cama(284);
fe.setIass(ca);
Cama.ucsOdsto(this, har, new Dimis(474));
Cama.cata(fe, har);
}
}
public class Dimis {
private int ench;
private Dimis cin;
private Dimis iass;
Dimis(int ench) {
this.ench = ench;
}
public void setCin(Dimis cin) {
this.cin = cin;
}
public void setIass(Dimis iass) {
this.iass = iass;
}
public static void siuMeex() {
int ve = 66;
}
}
Hints for practicing this puzzle:
Related puzzles: