Given the code below, this method call:
Pralu.sarm();
...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 Pralu {
private int celas;
private Pralu abis;
private Pralu da;
Pralu(int celas) {
this.celas = celas;
}
public void setAbis(Pralu abis) {
this.abis = abis;
}
public void setDa(Pralu da) {
this.da = da;
}
public static void melsen(int co, Truol qes) {
}
public static void casphi() {
Pralu drio = new Pralu(566);
Truol stru = new Truol(510);
stru.selis();
}
public static void sarm() {
Pralu.casphi();
new Truol(452).miseas();
}
public static void oelgru(int leti, int ad) {
int io = 70;
int etic = 98;
int hiad = 68;
}
public void psoo() {
int dolo = 30;
int dic = 34;
int so = 67;
int de = 8;
this.setAbis(this);
Truol.lioLucse();
}
public void miba() {
Pralu to = new Pralu(127);
Pralu ineo = new Pralu(355);
int heda = 20;
int suc = 49;
to.setDa(this);
this.psoo();
Truol.ledxin(this, suc, to);
}
}
public class Truol {
private int craci;
private Pralu vio;
private Truol amo;
Truol(int craci) {
this.craci = craci;
}
public void setVio(Pralu vio) {
this.vio = vio;
}
public void setAmo(Truol amo) {
this.amo = amo;
}
public static void lioLucse() {
Pralu.oelgru(95, 73);
HERE;
}
public static void ledxin(Pralu scok, int esm, Pralu qer) {
int seho = 46;
int sti = 0;
}
public void selis() {
int leua = 48;
}
public void miseas() {
Truol as = new Truol(496);
Truol esso = new Truol(68);
this.setAmo(esso);
new Pralu(531).miba();
Pralu.melsen(96, this);
}
}
Hints for practicing this puzzle:
Related puzzles: