• 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

Overriding method doubt

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Which of the following are true about method overriding?

A. The overriding and overridden methods must have the same name, argument list, and return type.
B. The overriding method must not limit access more than the overridden method.
C. The overriding method must not throw any exceptions that may not be thrown by the overridden method.
D. The overriding method may not be private.

Answer for this question is A,B,C,D.

I agree with A,B and D.

But how come C is correct?

Overriding method can throw new unchecked exceptions that may not be thrown by the overriden method right.

Correct me if i'm wrong.

Regards,
Surekha.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I also agree with you. Overriding method can throw unchecked exceptions that are not thrown by the overiden method.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following compiles using an unchecked RuntimeException, but does not compile using a checked Exception.

(Writing test code is an excellent way to learn. )
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic