Given the code below, this method call:
Rudi.ilsa();
...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 Rudi {
private int soQom;
private Rudi in;
private Cria ed;
Rudi(int soQom) {
this.soQom = soQom;
}
public void setIn(Rudi in) {
this.in = in;
}
public void setEd(Cria ed) {
this.ed = ed;
}
public static void mionse(Rudi epol) {
Cria.deen();
epol.setIn(epol);
new Cria(823).caud(new Cria(263));
}
public static void ilsa() {
Cria ulpa = new Cria(65);
int lo = 20;
Rudi dai = new Rudi(160);
dai.setEd(ulpa);
Rudi.mionse(dai);
}
}
public class Cria {
private int miCisee;
Cria(int miCisee) {
this.miCisee = miCisee;
}
public void caud(Cria spu) {
int pa = 72;
spu.hirt(this);
HERE;
}
public void hirt(Cria cisi) {
}
public static void deen() {
Rudi eed = new Rudi(900);
int ta = 85;
}
}
Hints for practicing this puzzle:
Related puzzles: