Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 75634
354
  • 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 !!!
 
Paper jam tastes about as you would expect. Try some on this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic