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 Gc question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Gc question" Watch "Gc question" New topic
Author

Gc question

Rosemol Thanjappan
Ranch Hand

Joined: Aug 08, 2000
Posts: 40
Hi,
I am little bit confused about this question.
Please Help me.

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 your object's memory as soon as it becomes a candidate for garbage collection.
E. The garbage collector runs in low-memory situations.

My choices are :
A.false
B.false
C.false
D.false
E.true
Correct me if I am wrong.
Thanking you
Rosemol.
Rajiv Ranjan
Ranch Hand

Joined: Sep 28, 2000
Posts: 61
I think only valid choice is c.
Rosemol Thanjappan
Ranch Hand

Joined: Aug 08, 2000
Posts: 40

Hi ,
Originally posted by Rajiv Ranjan:
I think only valid choice is c.

Option C. The garbage collector informs your object when it is about to be garbage collected.
How is garbage Collector informs ?

Thanking you
Rosemol.
Sam Zheng
Ranch Hand

Joined: Nov 29, 2000
Posts: 61
By calling the finalize() method of the object.
Vijayakumar Ramakrishnan
Greenhorn

Joined: Dec 16, 2000
Posts: 24
I go for C,E.
C is done by giving a call the protected void finalize() throws Throwable method of the Object.
E is true coz gc is a low priority thread.
Vandanam,
Vijay
Ashish Agarwal
Ranch Hand

Joined: Dec 02, 2000
Posts: 36
The only correct answer is c. Before collecting object's memoty gc invokes finalize().
Low priority thread does not mean that gc will run in low memory situations. You can never predict when gc is going to run, not even System.gc() ensures that.
Ashish
Rosemol Thanjappan
Ranch Hand

Joined: Aug 08, 2000
Posts: 40
Thank you all,
Now I chose only Option C.
Since low priority does not means low memory and Garbage Colletion cannot be predicted
Thanking you all
Rosemol.
 
jQuery in Action, 2nd edition
 
subject: Gc question
 
Similar Threads
From Boone's Exam Again
JQuest Mock Exam
another GC (levteck.com)
Booney mock exam q#65
Reg. GC