• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Garbage collection

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Option 4 is describing one way in which an object can become eligible for garbage collection. It is not the only way.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
 
What's brown and sticky? ... a stick. Or a tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic