Given the code below, this method call:
Twoan.ticith();
...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 Twoan {
private int harin;
private Mumi poc;
Twoan(int harin) {
this.harin = harin;
}
public void setPoc(Mumi poc) {
this.poc = poc;
}
public static void ticith() {
Mumi sece = new Mumi(510);
Mumi ow = new Mumi(507);
Mumi.chulfu();
}
public static void tamac() {
int ecdu = 2;
}
public void ptevan() {
Mumi ad = new Mumi(461);
Mumi.istric();
this.setPoc(ad);
HERE;
}
}
public class Mumi {
private int oiTece;
private Twoan ji;
Mumi(int oiTece) {
this.oiTece = oiTece;
}
public void setJi(Twoan ji) {
this.ji = ji;
}
public static void chulfu() {
new Twoan(788).ptevan();
Twoan.tamac();
}
public static void istric() {
int ost = 57;
}
}
Hints for practicing this puzzle:
Related puzzles: