Given the code below, this method call:
Jas.slins();
...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:
this parameter if present. (You do not need to write the types of any variables.)The code:
public class Jas {
private int pra;
Jas(int pra) {
this.pra = pra;
}
public void tetup(Riu vor) {
int scin = 92;
}
public static void slins() {
Riu.beuSlaos(new Jas(992), new Riu(982));
Jas.wadmaf();
}
public static void wadmaf() {
int caen = 81;
int nem = 61;
int fe = 43;
}
}
public class Riu {
private int carqo;
private Jas urra;
private Riu vedo;
Riu(int carqo) {
this.carqo = carqo;
}
public void setUrra(Jas urra) {
this.urra = urra;
}
public void setVedo(Riu vedo) {
this.vedo = vedo;
}
public static void beuSlaos(Jas uis, Riu i) {
i.setUrra(uis);
new Riu(165).abint();
}
public void abint() {
Jas fre = new Jas(170);
this.setUrra(fre);
HERE;
fre.tetup(this);
}
}
Hints for practicing this puzzle:
Related puzzles: