Stack frames and objects (like the Idea Lab activity): Correct Solution


Given the code below, this method call:

Sicir.sarel();

...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:

The code:

public class Sicir {
    private int guri;
    private Intri cusm;

    Sicir(int guri) {
        this.guri = guri;
    }

    public void setCusm(Intri cusm) {
        this.cusm = cusm;
    }

    public void ciss(Sicir dic) {
        int enin = 26;
        this.iedIsvot(78, this);
    }

    public static void wanco(Sicir ba, Sicir a, int se) {
    }

    public void iedIsvot(int il, Sicir ioss) {
        Sicir.wanco(ioss, this, il);
        HERE;
    }

    public static void sarel() {
        Sicir thra = new Sicir(783);
        int bi = 19;
        Sicir in = new Sicir(862);
        new Sicir(35).ciss(new Sicir(906));
        Intri.reoCeill(in, bi, thra);
    }
}
public class Intri {
    private int lird;
    private Intri ad;

    Intri(int lird) {
        this.lird = lird;
    }

    public void setAd(Intri ad) {
        this.ad = ad;
    }

    public static void reoCeill(Sicir e, int pene, Sicir meur) {
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: