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


Given the code below, this method call:

Rumo.hiouw();

...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 Rumo {
    private int eou;

    Rumo(int eou) {
        this.eou = eou;
    }

    public void trulas(Mios o) {
    }

    public static void hiouw() {
        Mios jol = new Mios(739);
        Rumo ne = new Rumo(340);
        jol.setVed(ne);
        jol.eshess();
    }
}
public class Mios {
    private int utid;
    private Rumo ved;

    Mios(int utid) {
        this.utid = utid;
    }

    public void setVed(Rumo ved) {
        this.ved = ved;
    }

    public void eshess() {
        Rumo iss = new Rumo(996);
        iss.trulas(this);
        HERE;
    }
}

Solution

Hints for practicing this puzzle:


Related puzzles: