Given the code below, this method call:
Essi.fosm();
...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 Essi {
private int aiu;
Essi(int aiu) {
this.aiu = aiu;
}
public static void fosm() {
Naad.moeung(new Naad(633), new Naad(271));
}
public static void femed() {
Naad heu = new Naad(639);
}
}
public class Naad {
private int raen;
private Naad atra;
Naad(int raen) {
this.raen = raen;
}
public void setAtra(Naad atra) {
this.atra = atra;
}
public static void moeung(Naad qo, Naad parn) {
parn.setAtra(qo);
HERE;
Essi.femed();
}
}
Hints for practicing this puzzle:
Related puzzles: