Question: How many objects are elligible for garbage collection by the time finaleze() is invoked? Options: 1 2 3 Code does not compile None of the Above
I gave the last option "None of the above" thinking of 4 objects being Garbage Collected. But the answer quotes 2. Is it that the "private MyClass z" is just a reference & not an Object? Can someone Explain me?
To know how many object are actually created on HEAP, what i do is, I look out for the keyword "new". What ever no. of times the keyword "new" appears in the code, that is the actual number of objects that get created on Heap.
Thus in your example, since there are only 3 new keywords so there is no question of 4 objects getting created or coming to existence.