wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage Collection" Watch "Garbage Collection" New topic
Author

Garbage Collection

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Which statements were true about GC?
a. You can directly free the memory allocated by an object.
b. You can directly run the garbage collector whenever you want to.
c. The garbage collector informs your object when it is about to be garbage collected.
d. The garbage collector reclaims your object's memory as soon as it becomes a candidate for garbage collection.
e. The garbage collector runs in low memory situations.
f. GC mechanism strictly defined in the JVM.
Please someone tell me the correct answers?
Paul A
Ranch Hand

Joined: Aug 25, 2000
Posts: 44
a. You can directly free the memory allocated by an object.
False. Memory can only be freed by the GC. (It's the boss out there!)
b. You can directly run the garbage collector whenever you want to.
False. You can only request. (by calling System.gc() etc.) When it actually runs depends (on its mood??) ...on it's implementation.
c. The garbage collector informs your object when it is about to be garbage collected.
True. by calling finalize() on that object.
d. The garbage collector reclaims your object's memory as soon as it becomes a candidate for garbage collection.
False. It reclaims the memory when it runs and not when the object becomes available for gc.
e. The garbage collector runs in low memory situations.
False. Not Neccessory. Somebody may write a JVM that runs the GC every 10 mins! It's not specified by Sun.
f. GC mechanism strictly defined in the JVM.
All it says is that the object's finalize() will be called just before it is GCed. Now, I don't know whether it is strictly defined or not. I would guess, No.
HTH,
Paul.
------------------
http://pages.about.com/jqplus
Get Certified, Guaranteed!


<A HREF="http://pages.about.com/jqplus" TARGET=_blank rel="nofollow">http://pages.about.com/jqplus</A> <BR>Get Certified, Guaranteed!
 
Don't get me started about those stupid light bulbs.
 
subject: Garbage Collection
 
Similar Threads
Booney mock exam q#65
some Qs from javahomepage???
gc
a question about GC
Garbage collection