aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface and 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 "Interface and exceptions" Watch "Interface and exceptions" New topic
Author

Interface and exceptions

Hans Beck�rus
Greenhorn

Joined: Aug 23, 2006
Posts: 24
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

Joined: Feb 07, 2005
Posts: 643

Check comments in above code.
Make changes according comments and see the result.
Try to understand compiler error messages.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023

[ August 30, 2006: Message edited by: wise owen ]
Hans Beck�rus
Greenhorn

Joined: Aug 23, 2006
Posts: 24
Thanks guys. That did the trick.
Now it is all crystal clear!
joy peter
Greenhorn

Joined: Aug 29, 2006
Posts: 13
Non abstract implementation class can throw broader exceptions but not new surprise exceptions that are not in super class.


Awake Arise and Stop Not Till Your goal is reached
 
Don't get me started about those stupid light bulbs.
 
subject: Interface and exceptions
 
Similar Threads
Interface method implementation
Exceptions.
Exam Watch on page 108 of the SCJP K&B book
Exception Handling with Inheritance
Rules for component interface and home interface