• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in garbage collection

 
Michael Lin
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 78.
If a Runtime Exception is thrown in the finalize method -

1.The running application crashes.
2.The exception is simply ignored and the object is garbage collected.
3.The exception is simply ignored, but the object is not garbage collected.
4.The Exception causes the JVM to crash.

the answer is 2,
but I think should be 3, reading from the api.
can someone please correct this??
 
dheeraj chopra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
option 2
 
vadiraj vd
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Michael the answer is 2.
The GC will catch any exception that have generated in finalize()
but ignores them. If the GC wants to garbage collect the current
object then it will gabage collect it.
Refer Khalid about this. page no. 256 q8.3.


------------------
Regards
---------
vadiraj

*****************
There's a lot of I in J.
*****************
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic