Given the code below, this method call:
Ulcai.sleChedgi();
...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 Ulcai {
private int hibri;
Ulcai(int hibri) {
this.hibri = hibri;
}
public static void sleChedgi() {
Athan neu = new Athan(541);
Ulcai.argess(neu);
neu.setCi(neu);
neu.welHabust(new Ulcai(555));
}
public static void farhin(Athan mi, Athan slec) {
Ulcai cec = new Ulcai(169);
}
public static void argess(Athan mu) {
int ma = 55;
}
}
public class Athan {
private int cel;
private Athan ci;
private Athan os;
Athan(int cel) {
this.cel = cel;
}
public void setCi(Athan ci) {
this.ci = ci;
}
public void setOs(Athan os) {
this.os = os;
}
public void welHabust(Ulcai is) {
Ulcai.farhin(new Athan(55), this);
new Athan(798).posra(is);
}
public void posra(Ulcai ood) {
int stec = 28;
this.setCi(this);
HERE;
}
}
Hints for practicing this puzzle:
Related puzzles: