• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JQ+: Question ID :960680824810

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question ID :960680824810
An overriding method can declare ArithmaticException in it's throws clause even if the overridden method does not have any throws clause.
True or False.
I chose "False". I must admit, wording is really confusing. Can someone clarify this for me? Thanks alot.
 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Question ID :960680824810
An overriding method can declare ArithmaticException in it's throws clause even if the overridden method does not have any throws clause.
True or False.


Hi, the answer is True. Because the ArithmeticException is an unchecked exception(runtime exception) and thus does not need to be caught or handled.
Clement
 
Rodney Woodruff
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Clement! The wording was really confusing. I get it now. I just wish that they could have worded it a little better.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does that mean that there are no restrictions on an overriding method in the throws clause incase of unchecked exceptions?
If the overriden method does not specify any unchecked exceptions,still the overriding method can specify them in its throws clause.
Is this right?
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are no rules based on unchecked exceptions. That's why they're called "unchecked" exceptions. In fact, even if a method declares that it throws an unchecked exception, the invoking method need not handle it.
This code compiles and runs fine:

Corey
 
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic