• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

behaviour of Overriding methods in exceptions

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, i want to ask that what did broader exception means , in context of that overriding methods cannot declare broader exceptions than overriden/original methods.
i want to know about what does broader exception means here?

broader exceptions means exception of parent class eg:

class subException extends Exception{}
class subsubException extends subException{}

class c{ void mehtod() throw subException{}
}
class b extends c{void method() throw Exception{}}

actually i was preparing for scjp6 and i encountered this question? itz so confusing that what exception can method() of class b can throw legally ?
what are broader exceptions ?
 
simranjit singh sandhu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does Broader Exception means Exceptions classes above current Exception in Exception Hierarchy ?
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look in the Java Language specification and all your questions will be answered.

. . . same exception class or one of its supertypes . . .

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A method that overrides a method from a superclass or interface cannot throw checked exceptions that have not been declared by the method that it is overriding.

 
simranjit singh sandhu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks !!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic