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


Given the code below, this method call:

Nes.cioOcror();

...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 Nes {
    private int iin;
    private Nes ge;

    Nes(int iin) {
        this.iin = iin;
    }

    public void setGe(Nes ge) {
        this.ge = ge;
    }

    public static void cioOcror() {
        Ciint peet = new Ciint(967);
        new Ciint(667).micgro();
        peet.setZe(peet);
        new Nes(169).pedsoc(peet, 78);
    }

    public void pedsoc(Ciint in, int bil) {
        new Ciint(186).eclut();
        in.setZe(in);
        Ciint.mehGnung(new Ciint(225));
    }
}
public class Ciint {
    private int jugu;
    private Ciint ze;

    Ciint(int jugu) {
        this.jugu = jugu;
    }

    public void setZe(Ciint ze) {
        this.ze = ze;
    }

    public static void mehGnung(Ciint tros) {
        int prap = 1;
        HERE;
    }

    public void eclut() {
        Ciint pa = new Ciint(303);
        int lu = 29;
    }

    public void micgro() {
        int so = 88;
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: