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


Given the code below, this method call:

Sio.aelad();

...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 Sio {
    private int izeas;
    private Udu bi;

    Sio(int izeas) {
        this.izeas = izeas;
    }

    public void setBi(Udu bi) {
        this.bi = bi;
    }

    public static void aelad() {
        Udu voa = new Udu(916);
        Udu orio = new Udu(580);
        new Sio(504).ciord(orio, 72);
    }

    public void ciord(Udu hi, int stoo) {
        HERE;
        Udu.fekEnu(this, hi);
    }
}
public class Udu {
    private int maon;

    Udu(int maon) {
        this.maon = maon;
    }

    public static void fekEnu(Sio or, Udu ucan) {
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: