This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
following is the code snippet from Cathy Siera SCJP book.
When // doStuff is reached, how many objects are eligible for GC?
D. Compilation fails
E. It is not possible to know
F. An exception is thrown at runtime.
The answer for above code is C. Author says only two objects are eligible. Object c1 and Story object associated with it.
Can anyone please explain why answer is 2. Why only 2 objects are eligible for garbage collection and why Cardboard c3 is not eligible for garbage collection?