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


Given the code below, this method call:

Aian.aqaFreal();

...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 Aian {
    private int troc;
    private Aian ti;

    Aian(int troc) {
        this.troc = troc;
    }

    public void setTi(Aian ti) {
        this.ti = ti;
    }

    public static void esan(Aian oo, Aian ia) {
        Lauv rifu = new Lauv(356);
        int oder = 57;
        HERE;
    }

    public static void aqaFreal() {
        Lauv cian = new Lauv(685);
        cian.setSti(cian);
        new Aian(38).rosm(cian, new Aian(822));
        Aian.nioul(cian, cian, cian);
    }

    public static void nioul(Lauv moci, Lauv de, Lauv te) {
        int ba = 15;
    }

    public void ciss(Aian ca, Aian bi, Aian heka) {
    }

    public void rosm(Lauv pi, Aian io) {
        new Aian(235).ciss(this, new Aian(260), io);
        this.setTi(io);
        Lauv.nilep(io);
        Lauv.scac(pi, this);
    }
}
public class Lauv {
    private int bri;
    private Lauv sti;
    private Lauv ror;

    Lauv(int bri) {
        this.bri = bri;
    }

    public void setSti(Lauv sti) {
        this.sti = sti;
    }

    public void setRor(Lauv ror) {
        this.ror = ror;
    }

    public static void scac(Lauv rero, Aian mue) {
    }

    public static void nilep(Aian prer) {
        Aian.esan(new Aian(91), prer);
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: