Given the code below, this method call:
Pec.scoc();
...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 Pec {
private int blups;
private Beir ne;
Pec(int blups) {
this.blups = blups;
}
public void setNe(Beir ne) {
this.ne = ne;
}
public static void stanis(int chie) {
Beir tral = new Beir(112);
Pec iun = new Pec(511);
new Beir(586).zong(tral, chie, new Pec(995));
iun.setNe(tral);
Beir.blis(tral, chie, iun);
}
public static void scoc() {
Pec go = new Pec(42);
int cluc = 82;
int e = 45;
Pec.stanis(15);
Beir.edspe(go);
}
}
public class Beir {
private int icpon;
private Pec sa;
private Pec vadi;
Beir(int icpon) {
this.icpon = icpon;
}
public void setSa(Pec sa) {
this.sa = sa;
}
public void setVadi(Pec vadi) {
this.vadi = vadi;
}
public static void blis(Beir ci, int hil, Pec de) {
ci.setVadi(de);
Beir.plodi();
}
public static void acra() {
int vid = 34;
}
public void zong(Beir te, int iges, Pec al) {
}
public static void edspe(Pec pa) {
int boeg = 35;
}
public static void plodi() {
Beir seod = new Beir(733);
Beir ra = new Beir(429);
Beir.acra();
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: