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

Garbage Collection

 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all
Which statements true about garbage collection mechanism?
a. The garbage collection mechanism releases memory at predictable time
b. a correct program must not depend on the time or order of Garbage collection
c. Garbage collection ensures that a program will not run out of memory during execution
d. The programmer can be indicate that a reference through a local variable is no longer going to be used
e. The programmer has a mechanism that explicitly an immediately frees the memory used by java objects
My answer is b and c.
Can someone correct me if I am wrong ?
thanks
daniel
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fisher
I would say the correct answers are B and D.
A is wrong because the GC is a low level thread and you cant say for sure when it'll run.
C is wrong because you can still run out of memory either through poor programming or just by using too many resourses in you code.
E is wrong because there is no way to explicitly destroy an object and release it memory.
B is correct because there is no set time the GC runs so you shouldn't count on specific behavior in your code.
D is correct (if I read it correctly) because, as the programmer you can indicate that an object is no longer going to used by setting all references to it to null.

------------------
Dave
Sun Certified Programmer for the Java� 2 Platform
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic