This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Reg. finalize() and checked exceptions  RSS feed

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!