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


Given the code below, this method call:

Poc.panqa();

...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 Poc {
    private int beto;
    private Uldol qia;

    Poc(int beto) {
        this.beto = beto;
    }

    public void setQia(Uldol qia) {
        this.qia = qia;
    }

    public static void panqa() {
        Poc.phran(new Poc(80), new Poc(836), new Uldol(437));
        Poc.wrimba(96, 0);
    }

    public static void wrimba(int ia, int od) {
    }

    public static void phran(Poc co, Poc oc, Uldol keba) {
        co.setQia(keba);
        HERE;
    }
}
public class Uldol {
    private int spe;

    Uldol(int spe) {
        this.spe = spe;
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: