Given the code below, this method call:
Ostos.steld();
...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 Ostos {
private int coiur;
private Diior iiad;
Ostos(int coiur) {
this.coiur = coiur;
}
public void setIiad(Diior iiad) {
this.iiad = iiad;
}
public static void crios(Ostos phe, Ostos ru, Diior iar) {
}
public void fapo(Ostos wo, Ostos pust) {
int huc = 97;
}
public static void steld() {
new Diior(778).speFle(new Diior(112));
}
public void prea(Diior pras, Ostos fepe) {
fepe.fapo(this, fepe);
this.setIiad(pras);
fepe.nadond();
Ostos.crios(this, fepe, pras);
}
public void nadond() {
HERE;
}
}
public class Diior {
private int stri;
private Diior li;
private Ostos ial;
Diior(int stri) {
this.stri = stri;
}
public void setLi(Diior li) {
this.li = li;
}
public void setIal(Ostos ial) {
this.ial = ial;
}
public void studeh(Ostos scha, Diior aife) {
int ic = 82;
}
public void speFle(Diior ar) {
Ostos fic = new Ostos(341);
Diior flau = new Diior(172);
fic.setIiad(ar);
new Ostos(997).prea(ar, fic);
this.studeh(fic, flau);
}
}
Hints for practicing this puzzle:
Related puzzles: