• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

basic interface doubt

 
adam Lui
Ranch Hand
Posts: 186
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K&B:
"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..???
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:




Yours,
Bu.
[ November 06, 2007: Message edited by: Burkhard Hassel ]
 
Nabila Mohammad
Ranch Hand
Posts: 661
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can declare all,none or subset of the exceptions declared in the Interface.
No new ones.
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic