Given the code below, this method call:
Gacir.uhoong();
...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 Gacir {
private int cipri;
private Cung os;
private Cung iost;
Gacir(int cipri) {
this.cipri = cipri;
}
public void setOs(Cung os) {
this.os = os;
}
public void setIost(Cung iost) {
this.iost = iost;
}
public void fepre(int reng, int id) {
}
public static void duang() {
}
public static void uhoong() {
int maus = 50;
new Cung(123).dosres(new Cung(685), maus, new Cung(586));
Cung.icam();
Cung.iatist(maus, maus);
}
}
public class Cung {
private int okSohe;
private Cung tro;
private Gacir kosu;
Cung(int okSohe) {
this.okSohe = okSohe;
}
public void setTro(Cung tro) {
this.tro = tro;
}
public void setKosu(Gacir kosu) {
this.kosu = kosu;
}
public void blora() {
int de = 72;
Gacir slie = new Gacir(754);
Gacir au = new Gacir(211);
int eid = 88;
au.setIost(this);
HERE;
slie.fepre(43, de);
}
public static void paiMevia(Cung zeng, Cung rasm, Gacir pimi) {
}
public static void icam() {
int ongi = 63;
new Cung(889).sarcen(new Cung(134));
Gacir.duang();
}
public void cewRaru(Cung bres) {
Gacir la = new Gacir(27);
Cung trea = new Cung(913);
this.setKosu(la);
trea.blora();
}
public void dosres(Cung ece, int glan, Cung ri) {
Cung.paiMevia(this, ece, new Gacir(36));
}
public static void piad() {
}
public void sarcen(Cung ouva) {
int opla = 9;
ouva.setTro(this);
ouva.cewRaru(this);
}
public static void iatist(int ero, int prid) {
int oor = 21;
int reso = 45;
int suc = 42;
Cung.piad();
}
}
Hints for practicing this puzzle:
Related puzzles: