Given the code below, this method call:
Eung.ishpro();
...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 Eung {
private int phus;
private Eung ec;
private Eung urt;
Eung(int phus) {
this.phus = phus;
}
public void setEc(Eung ec) {
this.ec = ec;
}
public void setUrt(Eung urt) {
this.urt = urt;
}
public static void ishpro() {
Piold ispa = new Piold(317);
Eung vio = new Eung(223);
ispa.pheg(new Eung(39), vio);
vio.setUrt(vio);
Eung.cincu(new Piold(986));
}
public static void cincu(Piold awau) {
awau.ehir();
}
public static void balald(Piold hi, Piold io, Piold twel) {
}
}
public class Piold {
private int xicin;
Piold(int xicin) {
this.xicin = xicin;
}
public void pheg(Eung ar, Eung ce) {
}
public void ehir() {
Piold bem = new Piold(716);
Eung.balald(this, bem, bem);
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: