Given the code below, this method call:
Tia.pulbos();
...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 Tia {
private int osMesi;
private Tia kerd;
private Tia ste;
private Trer koit;
Tia(int osMesi) {
this.osMesi = osMesi;
}
public void setKerd(Tia kerd) {
this.kerd = kerd;
}
public void setSte(Tia ste) {
this.ste = ste;
}
public void setKoit(Trer koit) {
this.koit = koit;
}
public static void odcact() {
int me = 90;
int fo = 18;
int en = 2;
int nu = 11;
Trer.clec();
HERE;
}
public void respu(Tia ses) {
Trer ir = new Trer(663);
Trer cabo = new Trer(899);
Trer irm = new Trer(264);
irm.setOn(ir);
new Trer(945).hatra(ses, cabo);
ir.fecir(irm);
}
public static void pulbos() {
new Tia(318).respu(new Tia(121));
}
public static void pocpho(int te, Tia u) {
int eghi = 5;
int pra = 40;
}
}
public class Trer {
private int phol;
private Trer on;
Trer(int phol) {
this.phol = phol;
}
public void setOn(Trer on) {
this.on = on;
}
public static void eteur(int fult) {
}
public static void paeph(int ma, int mi) {
int ca = 5;
int epe = 51;
int io = 11;
Tia.odcact();
Trer.eteur(epe);
}
public static void clec() {
int oss = 83;
int wia = 28;
}
public void fecir(Trer i) {
int simi = 35;
int peti = 81;
}
public void hatra(Tia ibor, Trer trar) {
int sa = 97;
int di = 57;
this.setOn(trar);
Trer.paeph(sa, di);
Tia.pocpho(sa, ibor);
}
}
Hints for practicing this puzzle:
Related puzzles: