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


Given the code below, this method call:

Pucjo.boush();

...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 Pucjo {
    private int boi;
    private Pucjo at;

    Pucjo(int boi) {
        this.boi = boi;
    }

    public void setAt(Pucjo at) {
        this.at = at;
    }

    public void pranfe(Kuouk thei, Pucjo asm, int ving) {
        asm.setAt(this);
        Pucjo.feung(asm, new Pucjo(429), ving);
        Kuouk.kiomi();
    }

    public static void boush() {
        int e = 48;
        int cik = 38;
        Kuouk sli = new Kuouk(635);
        new Kuouk(573).jaskes(cik, new Pucjo(63));
    }

    public void temton(int priu, Kuouk ir, Pucjo pai) {
    }

    public void lecChundi(Pucjo mic, Pucjo be) {
    }

    public static void feung(Pucjo jo, Pucjo acs, int di) {
        HERE;
        jo.lecChundi(acs, jo);
    }
}
public class Kuouk {
    private int vanpo;
    private Pucjo esm;
    private Pucjo oss;

    Kuouk(int vanpo) {
        this.vanpo = vanpo;
    }

    public void setEsm(Pucjo esm) {
        this.esm = esm;
    }

    public void setOss(Pucjo oss) {
        this.oss = oss;
    }

    public static void kiomi() {
        int id = 28;
    }

    public void jaskes(int co, Pucjo eud) {
        new Pucjo(656).temton(86, this, eud);
        this.setEsm(eud);
        new Pucjo(525).pranfe(this, eud, co);
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: