• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inheritance and exception

 
Chetan Parekh
Ranch Hand
Posts: 3640
  • 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
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx! both of you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic