Given the code below, this method call:
Gliat.poud();
...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 Gliat {
private int kiee;
private Gliat id;
private Psod ste;
Gliat(int kiee) {
this.kiee = kiee;
}
public void setId(Gliat id) {
this.id = id;
}
public void setSte(Psod ste) {
this.ste = ste;
}
public void sessto(int me, Gliat focs) {
int fu = 66;
}
public static void adprer() {
int aici = 2;
}
public void epan() {
new Psod(739).cleoud(this);
this.sessto(71, this);
}
public static void poud() {
int se = 60;
Gliat ao = new Gliat(511);
Psod ri = new Psod(601);
Psod gesh = new Psod(850);
gesh.setIl(ri);
ri.posrad(gesh);
}
public void kreRempme(Psod liur) {
int ad = 30;
int pher = 22;
}
}
public class Psod {
private int bilac;
private Psod il;
Psod(int bilac) {
this.bilac = bilac;
}
public void setIl(Psod il) {
this.il = il;
}
public void posrad(Psod iant) {
iant.setIl(this);
new Gliat(716).epan();
}
public void cleoud(Gliat stol) {
Gliat.adprer();
HERE;
stol.kreRempme(this);
}
}
Hints for practicing this puzzle:
Related puzzles: