This was taken from Boone's mock exam at: http://www.geocities.com/SiliconValley/Orchard/9362/java/javacert/newboone40-70.html Question #65 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. He gives the answer as b,c,e B is wrong though because while you can request the GC to run, you can not enforce it to run whenever you want to. C I am not sure about, can anyone help me with that one. E I know is true. Thanks, Bill
Jane Griscti
Ranch Hand
Joined: Aug 30, 2000
Posts: 3141
posted
0
Hi Bill, Think you're right about b; if it read "You can directly invoke the gc.." then it would be true. Using 'run' is, IMHO, misleading. As to c, according to Jamie Jaworski in Java 2 Certification one of the gc's activities is: <quote> Informing selected objects that they are no longer in use and that they should release any nonmemory resources. </quote> I think the informing bit has to do with the gc calling <code>finalize()</code> before destroying the object; since the Java Programming Language by Gosling and Arnold says the <code>finalize</code> method should be used to clean-up any non-memory items. Hope that helps. ------------------ Jane The cure for boredom is curiosity. There is no cure for curiosity. -- Dorothy Parker