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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "finalize()" Watch "finalize()" New topic
Author

finalize()

krussi rong
Ranch Hand

Joined: Jan 30, 2002
Posts: 62
Hi,
Here is the question:
If an object with a finalize() method has been
garbage collected, which of the following are
true about that object?
A The object became unreachable.
B The object's finalized() method was invoked by
the garbage collector.
C The memory used by the object is subject to
reuse.
D The object did not implement any interfaces.
The answer is A B
So why the C is not correct? I can't understand.
thanks
Krussi
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
Hi,
C The memory used by the object is subject to
reuse.
When GC destroys(!!!) object, this object doesn't exists!!!. That's why memory used by this object (not this object!!!) cannot be reused;
String str = new String("10");
str=null;
//think that str destroyed by GC
//here you can use str but
//String("10") is not accessible
Please look through JLS 12.6 and 12.7

Thanx,
Jamal Hasanov
www.j-think.com
Tony kunds
Greenhorn

Joined: Apr 25, 2002
Posts: 25
Hi jamal,
I think you are wrong.
the memory can be reused.
I am confused either.

help from any expertised person is appreciated.
-thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: finalize()