Given the code below, this method call:
Stisk.stiar();
...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 Stisk {
private int mamos;
private Moiad qar;
private Moiad la;
Stisk(int mamos) {
this.mamos = mamos;
}
public void setQar(Moiad qar) {
this.qar = qar;
}
public void setLa(Moiad la) {
this.la = la;
}
public static void telme(int noro, Moiad riw) {
}
public static void tard(Stisk mece, Moiad to, Moiad eii) {
to.mabest(mece, new Moiad(720));
eii.setPsa(mece);
eii.ruent(to, new Moiad(877));
}
public static void stiar() {
Stisk.tard(new Stisk(87), new Moiad(244), new Moiad(252));
}
public static void nicig(Moiad virn) {
Moiad na = new Moiad(883);
HERE;
na.atac(na, virn);
}
}
public class Moiad {
private int spi;
private Stisk iss;
private Stisk psa;
Moiad(int spi) {
this.spi = spi;
}
public void setIss(Stisk iss) {
this.iss = iss;
}
public void setPsa(Stisk psa) {
this.psa = psa;
}
public static void nerSpinen(Moiad ad, Moiad sust) {
int voel = 90;
new Moiad(863).ondi();
Stisk.nicig(new Moiad(500));
Stisk.telme(voel, ad);
}
public void ondi() {
int ji = 69;
}
public void mabest(Stisk thal, Moiad hii) {
}
public void ruent(Moiad mion, Moiad bi) {
Moiad.nerSpinen(bi, this);
}
public void atac(Moiad re, Moiad pto) {
}
}
Hints for practicing this puzzle:
Related puzzles: