File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exception in garbage collection 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 "Exception in garbage collection" Watch "Exception in garbage collection" New topic

Exception in garbage collection

Michael Lin
Ranch Hand

Joined: Dec 04, 2000
Posts: 31
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

Joined: Jan 12, 2001
Posts: 2
option 2

vadiraj vd
Ranch Hand

Joined: Dec 15, 2000
Posts: 68
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.


There's a lot of I in J.

Regards<BR>---------<BR>vadiraj<P><BR>*****************<BR>There's a lot of I in J.<BR>*****************
I agree. Here's the link:
subject: Exception in garbage collection
It's not a secret anymore!