JAVA INTERNALS, DRAWN LIVE
Three lines. One interview question.
Run them and watch the memory figure react. This is how every concept here works.
1Person a = new Person("Ada");
2Person b = a;
3a = null;
STACK
a · Person
◆ ref
b · Person
◆ ref
FIG 0Nothing exists yet. Run line 1.