wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage collector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage collector" Watch "Garbage collector" New topic
Author

Garbage collector

tushar parab
Greenhorn

Joined: Feb 11, 2009
Posts: 5
Hi,
following is the code snippet from Cathy Siera SCJP book.

Given:

When // doStuff is reached, how many objects are eligible for GC?
A. 0
B. 1
C. 2
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?
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1527
She's Kathy not Cathy.


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3658
    
  15
This question has been discussed many times here. Use the Search function to find these.


Joanne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage collector