Given the code below, this method call:
Teant.hism();
...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 Teant {
private int unimb;
Teant(int unimb) {
this.unimb = unimb;
}
public static void hism() {
Teant se = new Teant(588);
Teant fli = new Teant(767);
Gicne ro = new Gicne(501);
ro.setLi(ro);
new Gicne(505).iirhun();
}
}
public class Gicne {
private int nas;
private Gicne li;
private Teant leur;
private Gicne mo;
Gicne(int nas) {
this.nas = nas;
}
public void setLi(Gicne li) {
this.li = li;
}
public void setLeur(Teant leur) {
this.leur = leur;
}
public void setMo(Gicne mo) {
this.mo = mo;
}
public void kelPregs(int fle) {
Teant lict = new Teant(629);
}
public static void bricu(Gicne rhu) {
int eled = 27;
rhu.kelPregs(eled);
rhu.ceai(new Teant(974), eled, rhu);
Gicne.shelol(eled, rhu);
}
public static void shelol(int atch, Gicne aber) {
int us = 56;
int ni = 31;
}
public void iirhun() {
Gicne.osjan(this, new Gicne(675));
this.setLi(this);
Gicne.bricu(this);
}
public static void osjan(Gicne en, Gicne stal) {
Teant on = new Teant(761);
}
public void ceai(Teant tavo, int ogla, Gicne an) {
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: