Given the code below, this method call:
Cimo.rishra();
...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 Cimo {
private int chrel;
private Cimo erm;
Cimo(int chrel) {
this.chrel = chrel;
}
public void setErm(Cimo erm) {
this.erm = erm;
}
public static void rishra() {
int biac = 65;
Cimo dede = new Cimo(423);
int bri = 38;
dede.setErm(dede);
new Cimo(15).fonch();
}
public void skior(Cimo scod, int skac, Fli ri) {
}
public void fonch() {
Fli rere = new Fli(65);
Fli ab = new Fli(272);
Fli.thegi(ab, rere, this);
ab.setPreo(rere);
ab.oassam();
this.skior(this, 7, ab);
}
}
public class Fli {
private int suKhie;
private Fli preo;
Fli(int suKhie) {
this.suKhie = suKhie;
}
public void setPreo(Fli preo) {
this.preo = preo;
}
public static void thegi(Fli dus, Fli piah, Cimo as) {
}
public void oassam() {
int scen = 78;
int focu = 28;
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: