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


Given the code below, this method call:

Odol.weou();

...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 Odol {
    private int asne;

    Odol(int asne) {
        this.asne = asne;
    }

    public static void griac(Odol di, int eeco, Odol ma) {
    }

    public static void weou() {
        Odol lic = new Odol(658);
        new Usen(402).tioFexcec(lic, 53, new Usen(157));
        Odol.griac(lic, 38, lic);
    }
}
public class Usen {
    private int mosh;
    private Odol heu;

    Usen(int mosh) {
        this.mosh = mosh;
    }

    public void setHeu(Odol heu) {
        this.heu = heu;
    }

    public void tioFexcec(Odol in, int eani, Usen braf) {
        this.setHeu(in);
        HERE;
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: