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


Given the code below, this method call:

Hior.aspuen();

...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 Hior {
    private int tePoum;
    private Hior mi;
    private Ghod psuc;

    Hior(int tePoum) {
        this.tePoum = tePoum;
    }

    public void setMi(Hior mi) {
        this.mi = mi;
    }

    public void setPsuc(Ghod psuc) {
        this.psuc = psuc;
    }

    public void soleh(int to) {
        int noss = 57;
        int ip = 43;
        Ghod pid = new Ghod(399);
        new Hior(823).dessci(noss, this);
        pid.setEp(this);
        Hior.sassma(to);
    }

    public static void aspuen() {
        int coc = 93;
        Hior.asrin(coc, 5);
    }

    public void invam(Hior id, int nen, Hior gact) {
    }

    public static void sassma(int nec) {
        Ghod pe = new Ghod(330);
        Hior otha = new Hior(476);
        int psol = 34;
        int di = 74;
        pe.setEp(otha);
        Hior.tobea(otha, new Hior(12), psol);
    }

    public void dessci(int nes, Hior er) {
        int as = 62;
    }

    public void asplen(int hil) {
        Ghod ge = new Ghod(261);
        Ghod raan = new Ghod(153);
        Ghod ske = new Ghod(583);
    }

    public static void tobea(Hior pnao, Hior leri, int pisi) {
        HERE;
        leri.invam(pnao, 92, leri);
    }

    public static void asrin(int apos, int iop) {
        Hior pra = new Hior(228);
        new Hior(969).asplen(iop);
        pra.setMi(pra);
        pra.soleh(apos);
        Ghod.heftco(pra, iop, apos);
    }
}
public class Ghod {
    private int niarm;
    private Hior ep;
    private Ghod iist;

    Ghod(int niarm) {
        this.niarm = niarm;
    }

    public void setEp(Hior ep) {
        this.ep = ep;
    }

    public void setIist(Ghod iist) {
        this.iist = iist;
    }

    public static void heftco(Hior ma, int nees, int chep) {
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: