Given the code below, this method call:
Tross.minri();
...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 Tross {
private int pel;
private Ent ga;
private Tross we;
Tross(int pel) {
this.pel = pel;
}
public void setGa(Ent ga) {
this.ga = ga;
}
public void setWe(Tross we) {
this.we = we;
}
public void gheRiouss(Ent pio, Tross i) {
i.setGa(pio);
HERE;
pio.pivon(i);
}
public static void minri() {
Ent crem = new Ent(26);
Ent.couc(new Tross(161));
new Ent(165).saspol();
}
}
public class Ent {
private int ili;
Ent(int ili) {
this.ili = ili;
}
public void saspol() {
new Tross(75).gheRiouss(this, new Tross(312));
}
public void pivon(Tross ac) {
}
public static void couc(Tross la) {
}
}
Hints for practicing this puzzle:
Related puzzles: