This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes basic interface doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "basic interface doubt" Watch "basic interface doubt" New topic

basic interface doubt

adam Lui
Ranch Hand

Joined: Sep 03, 2007
Posts: 186
"in order to be a legal implementation class,
a nonabstrat implementation class must do the following:
-Declare no checked exceptions on implementation methods other than those declared by the interface method, or subclasses of those declared by the interface method.

i am soooo confused by this term.
is it refering a scenario like this..???

boolean b = true;<br />System.out.println ("I believe in Java.<br />Java will make my dream come " + b);
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
No, your code is perfectly legal if you remove the obvious error:

Both classes declare one of the Czech Exceptions and leave the other one out.

What you cannot do is to declare new, other Exceptions that aren't declared in the interface:

[ November 06, 2007: Message edited by: Burkhard Hassel ]

all events occur in real time
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
You can declare all,none or subset of the exceptions declared in the Interface.
No new ones.

The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
Originally posted by Nabila Mohammad:
You can declare all,none or subset of the exceptions declared in the Interface.
No new ones.

...except unchecked exceptions (i.e. subclasses of RuntimeException) and errors. You can declare any of those regardless of whether the original interface declares it.

SCJP 5.0
It is sorta covered in the JavaRanch Style Guide.
subject: basic interface doubt
Similar Threads
Abstract Class & Methods
SCJD book: Implementing two Interfaces
basic interface doubt
Checked exception and interface.