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


Given the code below, this method call:

Dinpa.blie();

...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 Dinpa {
    private int arsve;

    Dinpa(int arsve) {
        this.arsve = arsve;
    }

    public static void blie() {
        Iour sasu = new Iour(861);
        int ics = 99;
        sasu.setMi(sasu);
        sasu.tror(new Iour(333), sasu, ics);
    }
}
public class Iour {
    private int fal;
    private Iour mi;

    Iour(int fal) {
        this.fal = fal;
    }

    public void setMi(Iour mi) {
        this.mi = mi;
    }

    public void tror(Iour luss, Iour in, int ze) {
        HERE;
        luss.hoos(this);
    }

    public void hoos(Iour be) {
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: