This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Boone Exam3 question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Boone Exam3 question" Watch "Boone Exam3 question" New topic
Author

Boone Exam3 question

Nandini Gangopadhyay
Ranch Hand

Joined: Apr 02, 2001
Posts: 79
Hi all,
I need some help with this question I found in Boone's exam3,
Question 65: Which statements about garbage collection are true?
Select all valid answers.

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 an object´┐Żs memory as soon as it becomes a candidate for garbage collection.
e.The garbage collector runs in low-memory situations.
The answers given are b,c,e
My question is that is (b) a good choice because we know that we can only ask the garbage collector to run garbage collection using System.gc or Runtime.gc but it is totally at the discretion of the garbage collector when it wants to reclaim the resources.
Hoping to hear from u guys soon,
Nandini
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
This is a very ambiguous question. This is debated at least once a week here at JavaRanch. I would say c and e are correct. You can only suggest to run the garbage collector; you can't force it. You have to remember that garbage collection is implemented by the vendor, meaning that it can be slightly different on different jvm's.
Parimala Somasundaram
Ranch Hand

Joined: Mar 31, 2001
Posts: 41
I think b is a correct answer because we are only running the garbage collector usng System.gc or Runtime.gc
The answer choice is not talking about when the resources themselves are reclaimed.
Stevie Kaligis
Ranch Hand

Joined: Feb 04, 2001
Posts: 400
Hi Dini...
a.You can directly free the memory allocated by an object.
NO WAY....
b.You can directly run the garbage collector whenever you want to.
NO WAY...., you can REQUEST to run, but JVM will not guarantee to execute your request, (may be in the future Java should add a method for GC that returns a "magic word"...PLEEEASE !!!)
c.The garbage collector informs your object when it is about to be garbage collected.
YES..., by calling it's finalize() method.
d.The garbage collector reclaims an object?s memory as soon as it becomes a candidate for garbage collection.
NOPE...JVM doesn't guarantee ... even if "Julia Roberts" ask fot it...!!
e.The garbage collector runs in low-memory situations.
YES...also in medium, High, at the beach, while you sleep, while you eat, what ever..., there is no way you can predict about the behavior of GC.
the answer is : c & e
Nandini Gangopadhyay
Ranch Hand

Joined: Apr 02, 2001
Posts: 79
Thanks guys, I thought the same too!
Nandini
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Boone Exam3 question
 
Similar Threads
From Boone's Exam Again
another GC (levteck.com)
GC
garbage collection
Reg. GC