File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "garbage collection!" Watch "garbage collection!" New topic
Author

garbage collection!

ashok khetan
Ranch Hand

Joined: Jul 29, 2001
Posts: 153
hi,
which of these options are true for the following question?(from Boone's Mock-exam).
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.
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
I think the answer is b. You can call the garbage collector by invoking system.gc() method.But there is no gaurantee that the objeects will be collected immediately because garbage collection is usually performed in low memory conditions
Originally posted by ashok khetan:
hi,
which of these options are true for the following question?(from Boone's Mock-exam).
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.

Mini Pilla
Ranch Hand

Joined: Jul 15, 2001
Posts: 112
I think it is c and e.
rajani
Bindesh Vijayan
Ranch Hand

Joined: Aug 21, 2001
Posts: 104
I agree with Rajani.Since if you look at option b more carefully,it will be clear that the option says about running GC which is no gurantee at all.Of course, you can call System.gc() but again, as Roopa mentions,it is a request rather than running it.
THANKS.
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
I really don't understand option c. Could you please explain it
Originally posted by Bindesh Vijayan:
I agree with Rajani.Since if you look at option b more carefully,it will be clear that the option says about running GC which is no gurantee at all.Of course, you can call System.gc() but again, as Roopa mentions,it is a [b]request rather than running it.
THANKS.[/B]

Bindesh Vijayan
Ranch Hand

Joined: Aug 21, 2001
Posts: 104
Roopa,
Actually I think, what happens is when GC is to be done it calls finalize() on that particular object and this way it informs the object of being GC'd. You can view this phenomenon on the following code:

THANKS
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Thanks Bindesh. Good answer
Originally posted by Bindesh Vijayan:
[B]Roopa,
Actually I think, what happens is when GC is to be done it calls finalize() on that particular object and this way it informs the object of being GC'd. You can view this phenomenon on the following code:

THANKS[/B]

Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Thanks Bindesh. Good answer
Originally posted by Bindesh Vijayan:
[B]Roopa,
Actually I think, what happens is when GC is to be done it calls finalize() on that particular object and this way it informs the object of being GC'd. You can view this phenomenon on the following code:

THANKS[/B]

Bindesh Vijayan
Ranch Hand

Joined: Aug 21, 2001
Posts: 104
Roopa,
I would like to add here that, although the finalize is being called by Gc it's not Garbage Collection, still because it only does cleanup.And only when next time the finalize is callled the GC does the actual work on the object.This is what I studied in Thinking in Java, Bruce Eckel
Thanks.
 
Consider Paul's rocket mass heater.
 
subject: garbage collection!
 
Similar Threads
another GC (levteck.com)
Booney mock exam q#65
GC
garbage collection
Reg. GC