• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

garbage collection

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
I took the certification twice and i have failed in Garbage collection each time. Please tell me what's the best reference material on the net for it or some sample questions .
Thanks in advance.
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rachel,
There are keys to understanding garbage collection for exam purposes:
1. Objects no longer being referenced are eligible for gc.
2. An object set to 'null' is eligible for gc. This does not mean it 'will' be gc'd; there are no guarantees.
3. You cannot force the garbage collector to reclaim memory.
4. You can ask the gc to run by calling System.gc() or Runtime.getRuntime().gc but there is no guarantee that it 'will run'
5. An object's finalize() method will be called at least once before the object is gc'd
6. You must understand how Java passes parameters in methods! If you do not fully understand the handling of primitive variables vs reference variables you will no be able to determine if an object is being referenced after a method completes.
There's an article Understanding that parameters are passed by value and not by reference that helps explain the last point.
Hope that helps.
Please read the JavaRanch Name Policy and reregister using a name that complies with the rules.
Thanks for your cooperation.

Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
    Bookmark Topic Watch Topic
  • New Topic