Given the code below, this method call:
Nawe.scron();
...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 Nawe {
private int seion;
private Scic stos;
Nawe(int seion) {
this.seion = seion;
}
public void setStos(Scic stos) {
this.stos = stos;
}
public void ersa(Scic eck) {
Nawe a = new Nawe(599);
}
public void easm(Scic olme, Scic ua, Nawe ru) {
Scic.adpred();
this.setStos(ua);
ua.irmIngvul();
}
public void feic(Scic pesm) {
int u = 53;
int ro = 13;
}
public static void scron() {
Scic ia = new Scic(936);
Nawe vi = new Nawe(774);
Nawe pu = new Nawe(314);
new Nawe(305).ersa(ia);
pu.setStos(ia);
Scic.carta();
pu.feic(ia);
}
}
public class Scic {
private int dond;
private Scic alsa;
private Scic cri;
Scic(int dond) {
this.dond = dond;
}
public void setAlsa(Scic alsa) {
this.alsa = alsa;
}
public void setCri(Scic cri) {
this.cri = cri;
}
public static void carta() {
new Nawe(61).easm(new Scic(614), new Scic(405), new Nawe(636));
}
public void irmIngvul() {
HERE;
}
public static void adpred() {
int pa = 36;
int ei = 27;
int wret = 20;
}
}
Hints for practicing this puzzle:
Related puzzles: