Given the code below, this method call:
Cien.necder();
...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 Cien {
private int cas;
private Cien me;
private Cien he;
private Sco eaep;
Cien(int cas) {
this.cas = cas;
}
public void setMe(Cien me) {
this.me = me;
}
public void setHe(Cien he) {
this.he = he;
}
public void setEaep(Sco eaep) {
this.eaep = eaep;
}
public void rihot() {
HERE;
Sco.oant(this, this);
}
public static void necder() {
Sco cous = new Sco(636);
Sco enmi = new Sco(349);
int ost = 8;
cous.setChoi(enmi);
new Sco(847).udwap(enmi);
}
}
public class Sco {
private int doi;
private Sco choi;
Sco(int doi) {
this.doi = doi;
}
public void setChoi(Sco choi) {
this.choi = choi;
}
public void prisam(Cien ga) {
int hu = 78;
Cien ef = new Cien(532);
int whec = 87;
ef.setEaep(this);
Sco.pleh(ga);
this.eqil(ef, ga);
}
public void eqil(Cien pha, Cien idhu) {
int bre = 49;
}
public void udwap(Sco ol) {
ol.etep();
ol.setChoi(this);
new Sco(290).prisam(new Cien(632));
Sco.delier(ol);
}
public void etep() {
Cien eoac = new Cien(568);
Cien al = new Cien(633);
Sco paa = new Sco(955);
}
public static void pleh(Cien brud) {
int isud = 8;
brud.rihot();
}
public static void delier(Sco psos) {
}
public static void oant(Cien am, Cien gi) {
int mi = 87;
int rufa = 41;
}
}
Hints for practicing this puzzle:
Related puzzles: