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


Given the code below, this method call:

Fesm.vemseo();

...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 Fesm {
    private int ciss;
    private Fesm ples;

    Fesm(int ciss) {
        this.ciss = ciss;
    }

    public void setPles(Fesm ples) {
        this.ples = ples;
    }

    public static void vemseo() {
        Fesm er = new Fesm(773);
        Picso outt = new Picso(857);
        outt.irpur(outt, new Fesm(560));
    }
}
public class Picso {
    private int eze;

    Picso(int eze) {
        this.eze = eze;
    }

    public void irpur(Picso i, Fesm a) {
        HERE;
        this.priri();
    }

    public void priri() {
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: