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


Given the code below, this method call:

Wiic.proum();

...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 Wiic {
    private int orsia;

    Wiic(int orsia) {
        this.orsia = orsia;
    }

    public static void proum() {
        int u = 68;
        new Ipt(544).rornco(new Wiic(640));
    }

    public static void diesha(Ipt teci) {
    }
}
public class Ipt {
    private int moDerb;
    private Ipt issa;

    Ipt(int moDerb) {
        this.moDerb = moDerb;
    }

    public void setIssa(Ipt issa) {
        this.issa = issa;
    }

    public void rornco(Wiic lec) {
        Wiic.diesha(new Ipt(890));
        this.setIssa(this);
        HERE;
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: