Given the code below, this method call:
Stres.eckGroda();
...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 Stres {
private int wupin;
private Stres spac;
private Kes as;
Stres(int wupin) {
this.wupin = wupin;
}
public void setSpac(Stres spac) {
this.spac = spac;
}
public void setAs(Kes as) {
this.as = as;
}
public static void hierds() {
int ci = 12;
}
public static void eckGroda() {
Kes o = new Kes(559);
Stres pse = new Stres(975);
int ax = 5;
pse.setAs(o);
Kes.chesi(ax);
Stres.hierds();
}
}
public class Kes {
private int odsab;
Kes(int odsab) {
this.odsab = odsab;
}
public void dicua() {
Stres uc = new Stres(981);
int har = 45;
Kes.boeko();
uc.setAs(this);
HERE;
}
public static void boeko() {
int fel = 93;
int esel = 97;
int niod = 13;
}
public static void chesi(int psan) {
int ni = 29;
new Kes(199).dicua();
}
}
Hints for practicing this puzzle:
Related puzzles: