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


Given the code below, this method call:

Jae.rohot();

...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 Jae {
    private int reVuc;

    Jae(int reVuc) {
        this.reVuc = reVuc;
    }

    public static void rohot() {
        Jae mo = new Jae(728);
        Jae.nont();
    }

    public static void nont() {
        Jae crul = new Jae(154);
        Jae me = new Jae(141);
        HERE;
        Repso.tonid(crul);
    }
}
public class Repso {
    private int spes;
    private Jae trom;

    Repso(int spes) {
        this.spes = spes;
    }

    public void setTrom(Jae trom) {
        this.trom = trom;
    }

    public static void tonid(Jae qegi) {
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: