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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "finalize()" Watch "finalize()" New topic


krussi rong
Ranch Hand

Joined: Jan 30, 2002
Posts: 62
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
D The object did not implement any interfaces.
The answer is A B
So why the C is not correct? I can't understand.
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
C The memory used by the object is subject to
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");
//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

Jamal Hasanov
Tony kunds

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.
I agree. Here's the link:
subject: finalize()
It's not a secret anymore!