Given the code below, this method call:
Pec.peliu();
...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 cudto;
private Pec ia;
private Pec is;
Pec(int cudto) {
this.cudto = cudto;
}
public void setIa(Pec ia) {
this.ia = ia;
}
public void setIs(Pec is) {
this.is = is;
}
public static void peliu() {
int re = 32;
int mi = 70;
Ecel eae = new Ecel(314);
Ecel lo = new Ecel(304);
Ecel.addac(lo);
lo.jaster(re, mi, eae);
}
public static void bruiss(int or, int je) {
}
public static void dras() {
int ao = 50;
HERE;
Pec.bruiss(ao, ao);
}
}
public class Ecel {
private int dest;
private Pec odo;
Ecel(int dest) {
this.dest = dest;
}
public void setOdo(Pec odo) {
this.odo = odo;
}
public static void hoid(Ecel fo, int o, int phir) {
}
public void oinjo() {
int ad = 43;
int sa = 6;
int nas = 1;
Pec.dras();
Ecel.hoid(this, nas, sa);
}
public static void addac(Ecel a) {
Pec cex = new Pec(690);
Pec ne = new Pec(294);
a.setOdo(ne);
new Ecel(86).oinjo();
}
public void jaster(int ecen, int unad, Ecel du) {
}
}
Hints for practicing this puzzle:
Related puzzles: