In my studying for OCJP I came across the following question:
class CardBoard {
Short story = 200;
CardBoard go(CardBoard cb) {
Your CardBoard#go()
method does nothing. It receives reference to some object, immediately forgets it, replacing by null
, and returns this null
value.
So, the line
CardBoard c3 = c1.go(c2);
also does nothing, i.e. no object is created. Just null assigned to c3
. So it is not garbage collected because it is already not exist.