Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finalize()

 
krussi rong
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi jamal,
I think you are wrong.
the memory can be reused.
I am confused either.

help from any expertised person is appreciated.
-thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic