*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage collection 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 collection" Watch "Garbage collection" New topic
Author

Garbage collection

swarna dasa
Ranch Hand

Joined: Mar 15, 2007
Posts: 108
question from examulator

Which of the following statements are true?

1 The automatic garbage collection of the JVM prevents programs from ever running out of memory
2A program can suggest that garbage collection be performed but not force it
3 Garbage collection is platform independent
4 An object becomes eligible for garbage collection when all references denoting it are set to null.

Answer 2,4

Didn't understand why option 4 is right?
What about isolated circular objects, one refers to the other but all of them can be garbage collected.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Option 4 is describing one way in which an object can become eligible for garbage collection. It is not the only way.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707

4- An object becomes eligible for garbage collection when all references denoting it are set to null.


If you write option four as:


4 An object can only become eligible for garbage collection when all references denoting it are set to null.


Then it would be false.



Regards,
cmbhatt


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