Given the code below, this method call:
Uch.ceck();
...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 Uch {
private int irAr;
private Ashe ed;
private Ashe soa;
Uch(int irAr) {
this.irAr = irAr;
}
public void setEd(Ashe ed) {
this.ed = ed;
}
public void setSoa(Ashe soa) {
this.soa = soa;
}
public static void ceck() {
new Ashe(900).kaul();
new Ashe(43).twec(new Uch(7));
}
public void ujir() {
}
public static void shald(Ashe e) {
Ashe odec = new Ashe(833);
int pha = 80;
HERE;
}
}
public class Ashe {
private int trer;
Ashe(int trer) {
this.trer = trer;
}
public void kaul() {
Ashe ced = new Ashe(53);
}
public void twec(Uch mion) {
new Uch(591).ujir();
mion.setEd(this);
Uch.shald(this);
}
}
Hints for practicing this puzzle:
Related puzzles: