Q65 from Barry Boones mock exam. 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. Correct answers according to the mock are b,c,e. I have a few questions here- b. This seemed to be an incorrect option to me. GC can be invoked anytime by a program, but whether it runs or not, is entirely upto the JVM. So why is b a correct answer. c. I read somewhere that the finalize method is called for an object only once. If, in the finalize method, we 'revive' the reference again, then if gc is invoked a second time, the finalize method will not be called. If the above is true, then c does not seem to be a valid option.
Would appreciate if anyone could comment on this. Thanks Sajida
Hello experts, Put some more light on option b.Tell us it's correct or not.
Joined: Mar 29, 2001
Originally posted by nitin sharma: Hello experts, Put some more light on option b.Tell us it's correct or not.
Nitin, I am no expert , but i found the same q's in a old quote: Topic: Gc question posted December 25, 2000 07:45 PM and Topic: garbage collection posted December 26, 2000 10:13 PM this has lot of discussion on this topic. u can search for it. Regards Sharmila