This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance and exception

 
Chetan Parekh
Ranch Hand
Posts: 3640
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a declaration of a method in interface that throws a particular exception. I implement that interface and give the definition of the method � here I don�t throw any exception.

I am able to compile and run the code.

How can it possible?

Can anybody provide me with link that talks about rules of exception in inheritance?



 
wise owen
Ranch Hand
Posts: 2023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This Link:
You can also relax the specification by throwing a subset of those exceptions listed in the method's superclass or not throwing any exceptions at all in the overriding method of the subclass. You can not add new exception types to the overriding method.
 
Tony Morris
Ranch Hand
Posts: 1608
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by wise owen:
This Link:You can not add new exception types to the overriding method.


You can not add new checked exception types to the overriding method.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx! both of you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic