Given the code below, this method call:
Athes.prece();
...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 Athes {
private int jec;
private Shosa ac;
private Athes be;
private Athes ees;
Athes(int jec) {
this.jec = jec;
}
public void setAc(Shosa ac) {
this.ac = ac;
}
public void setBe(Athes be) {
this.be = be;
}
public void setEes(Athes ees) {
this.ees = ees;
}
public static void ceia(Shosa ipeh) {
Shosa se = new Shosa(105);
int nuc = 11;
int re = 51;
se.doos();
HERE;
Athes.vifil(nuc);
}
public static void prece() {
new Shosa(600).trel(new Shosa(843), new Shosa(745));
}
public static void vifil(int scas) {
int pa = 8;
int sa = 3;
}
}
public class Shosa {
private int ieng;
Shosa(int ieng) {
this.ieng = ieng;
}
public void iarSensad(Shosa isp) {
Athes.ceia(this);
this.thogi(isp, this);
}
public void thogi(Shosa ouss, Shosa is) {
}
public void doos() {
int ias = 26;
int ior = 93;
}
public void trel(Shosa e, Shosa lil) {
Shosa rak = new Shosa(632);
this.iarSensad(lil);
}
}
Hints for practicing this puzzle:
Related puzzles: