• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface and exceptions

 
Hans Beck�rus
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read the following
A legal nonabstract implementing class has the following properties:
...
- It must not declare any new checked exceptions for an implementation method.
- It must not declare any checked exceptions that are broader than the exceptions declared in the interface method.
...

I have some problem understanding how you could fulfil the first but fail to fulfil the second?

Anyone that could explain (maybe with a simple code example) how these rules correlate?
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Check comments in above code.
Make changes according comments and see the result.
Try to understand compiler error messages.
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ August 30, 2006: Message edited by: wise owen ]
 
Hans Beck�rus
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys. That did the trick.
Now it is all crystal clear!
 
joy peter
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Non abstract implementation class can throw broader exceptions but not new surprise exceptions that are not in super class.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic