• 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

confusing!

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question ID :960680664920
Overriding method cannot throw new exceptions that are not thrown by the overridden method.
Correct Answer:false!!!
Does it include Runtime Exceptions?
Thanks,
Rashmi
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is true only on checked exceptions.
 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi rashmi,
An overriding method can either throw only a subset of the exceptions thrown by the overridden method or all the exceptions thrown by the overridden method or a new exception which is a subclass of the exception thrown by the overridden method.The overriding method doesn't need to throw any exceptions at all since a subset of 0 elements is a valid subset.
However, an overriding method cannot throw an exception which is the superclass of the exception thrown by overridden method.
Hence the statement is false.
Also only checked exceptions(not RuntimeException and its subclasses)need to be mentioned in the throws clause of the method if not handled by the method itself.
HTH
rajashree.

[This message has been edited by rajashree ghatak (edited November 04, 2001).]
 
If you're gonna buy things, buy this thing and I get a fat kickback:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic