| Author |
Garbage Collection Question
|
Fes D Gaur
Ranch Hand
Joined: Apr 29, 2005
Posts: 54
|
|
I got this question from Bary Boon's mock exam. Q 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 and it will be schedule in due time.. 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 answer given is b,c,e. The exam was created before JVM 1.4. So I'm pretty sure that b is not correct. I think e is correct. How about c? Thanks, Fes
|
 |
Lakshmanan Arunachalam
Ranch Hand
Joined: Nov 02, 2005
Posts: 99
|
|
|
C is correct. GC will inform the objects when it goes to collect the objects, by calling finalize method on them.
|
Regards<br />Lakshmanan<br />IBM-OOAD & UML, SCEA-I
|
 |
Prabhu Venkatachalam
Ranch Hand
Joined: Nov 16, 2005
Posts: 502
|
|
In Java specifications make the following promise about finalize() method: Before reclaiming the memory occupied by an object that has a finalize() method, the garbage collector will invoke that object's finalize() method.
|
Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
|
 |
Naresh Gunda
Ranch Hand
Joined: Oct 15, 2005
Posts: 163
|
|
Hi -->The System.gc() method can be used to request garbage collection, -->Although Java provides facilities to invoke the garbage collection, explicitly, there are no guarantees that it will be run. The program can only request that garbage collection be performed, but there is no way that garbage collection can be forced. Above two statements says option 'b' is wrong know. friends, pls correct me if i am wrong. Thanx & Regards Naresh
|
 |
 |
|
|
subject: Garbage Collection Question
|
|
|