Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

basic interface doubt

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..???
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can declare all,none or subset of the exceptions declared in the Interface.
No new ones.
 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic