Given the code below, this method call:
Mehes.harPacin();
...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 Mehes {
private int iel;
private Mehes qin;
private Mehes edon;
Mehes(int iel) {
this.iel = iel;
}
public void setQin(Mehes qin) {
this.qin = qin;
}
public void setEdon(Mehes edon) {
this.edon = edon;
}
public void tapess() {
int bu = 97;
Mehes nago = new Mehes(815);
int scoc = 50;
}
public void sepe() {
int aerd = 39;
int biqi = 16;
}
public void sucic(int toic, Onbre ene) {
Onbre lera = new Onbre(75);
}
public static void harPacin() {
Onbre.eught(new Mehes(264), new Mehes(279), new Onbre(840));
Onbre.pehor(23, new Onbre(615));
}
}
public class Onbre {
private int idot;
private Onbre eou;
private Onbre pi;
Onbre(int idot) {
this.idot = idot;
}
public void setEou(Onbre eou) {
this.eou = eou;
}
public void setPi(Onbre pi) {
this.pi = pi;
}
public void prere(int dusm, Mehes senk) {
int toin = 17;
senk.setQin(senk);
this.henva(dusm, toin, new Onbre(743));
this.esmTiva(dusm, this, senk);
}
public static void histdo(int gesm, Onbre efun, Onbre frun) {
Mehes roum = new Mehes(954);
new Mehes(161).tapess();
HERE;
}
public static void eught(Mehes iam, Mehes acir, Onbre ii) {
Onbre rund = new Onbre(908);
Mehes alal = new Mehes(972);
new Mehes(344).sepe();
}
public static void pehor(int girf, Onbre nume) {
nume.setEou(nume);
nume.prere(girf, new Mehes(370));
new Mehes(118).sucic(girf, nume);
}
public void henva(int elu, int urot, Onbre ves) {
Onbre jeng = new Onbre(745);
this.setEou(jeng);
Onbre.histdo(urot, ves, this);
}
public void esmTiva(int lepi, Onbre gua, Mehes suou) {
Mehes cead = new Mehes(639);
}
}
Hints for practicing this puzzle:
Related puzzles: