File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Reg. finalize() and checked exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Reg. finalize() and checked exceptions " Watch "Reg. finalize() and checked exceptions " New topic
Author

Reg. finalize() and checked exceptions

Angela Narain
Ranch Hand

Joined: Apr 14, 2001
Posts: 327
In Khalid book it is mentioned that "Overidden method definitions
in subclasses will not be able to throw checked exceptions"
But when i overide the finalize() method ,i am able to throw
checked exception ? I think it should be possible as long
as the class is a subclass of java.lang.Throwable
shilpa kulkarni
Ranch Hand

Joined: Jun 07, 2000
Posts: 87
the siganture of finalize in Object is -
protected void finalize() throws Throwable
this is the reason why you can throw an Exception (a sub-class of Throwable) when you override finalize()
Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
Posts: 464
Originally posted by Angela Narain:
In Khalid book it is mentioned that "Overidden method definitions
in subclasses will not be able to throw checked exceptions"
But when i overide the finalize() method ,i am able to throw
checked exception ? I think it should be possible as long
as the class is a subclass of java.lang.Throwable

Overridden method will not able to throw checked exceptions
that are not subclass of the checked exception thats thrown by the method in the parent class. This is what khalid books refers to
Exceptions can be
1. Nuthing
2. Same Exceptions
3. Subclass of the exceptions
Ragu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reg. finalize() and checked exceptions
 
Similar Threads
Finalize method?
I'd like to would like to know the reason behind this statement.
Finalize ()
finalize() method
Can finalize() throw Exception?