Given the code below, this method call:
Pra.dreses();
...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 Pra {
private int odTro;
private Maf qal;
Pra(int odTro) {
this.odTro = odTro;
}
public void setQal(Maf qal) {
this.qal = qal;
}
public static void dreses() {
Maf acnu = new Maf(132);
Pra phiu = new Pra(821);
phiu.setQal(acnu);
acnu.esaIha(new Pra(598));
}
}
public class Maf {
private int prel;
Maf(int prel) {
this.prel = prel;
}
public void esaIha(Pra ic) {
HERE;
Maf.cleni(this, ic, this);
}
public static void cleni(Maf es, Pra re, Maf ro) {
}
}
Hints for practicing this puzzle:
Related puzzles: