This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

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
Greenhorn

Joined: Jan 12, 2001
Posts: 2
option 2


dheeraj
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.


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

*****************
There's a lot of I in J.
*****************


Regards<BR>---------<BR>vadiraj<P><BR>*****************<BR>There's a lot of I in J.<BR>*****************
 
GeeCON Prague 2014
 
subject: Exception in garbage collection