Given the code below, this method call:
Amei.macol();
...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 Amei {
private int repe;
private Amei de;
Amei(int repe) {
this.repe = repe;
}
public void setDe(Amei de) {
this.de = de;
}
public static void macol() {
Amei iung = new Amei(418);
int iuss = 62;
iung.setDe(iung);
new Amei(429).xuke(iuss, iung, new Amei(550));
}
public void esspam(int trel, Amei ro, Amei xess) {
}
public void xuke(int isun, Amei oid, Amei en) {
HERE;
en.esspam(isun, this, oid);
}
}
public class Edih {
private int haeni;
Edih(int haeni) {
this.haeni = haeni;
}
}
Hints for practicing this puzzle:
Related puzzles: