Given the code below, this method call:
Pren.leun();
...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 Pren {
private int sohe;
private Pren gric;
Pren(int sohe) {
this.sohe = sohe;
}
public void setGric(Pren gric) {
this.gric = gric;
}
public static void leun() {
Feni ma = new Feni(483);
Pren bi = new Pren(715);
new Feni(863).itin(bi);
bi.letre(85);
}
public void letre(int rirm) {
}
}
public class Feni {
private int usmdi;
Feni(int usmdi) {
this.usmdi = usmdi;
}
public void itin(Pren ba) {
ba.setGric(ba);
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: