• 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 and overloading

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have couple of questions.

1) Can a static method be overriden to be non-static?
2) Can an overloaded method throw an exception which is not checked in the base class?
 
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. No
2. Yes.

Originally posted by amit sanghai:
I have couple of questions.

1) Can a static method be overriden to be non-static?
2) Can an overloaded method throw an exception which is not checked in the base class?

 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rewording your second question:
2) Can an overridden method throw a checked exception which is not checked in the base class?
No.
[ July 26, 2003: Message edited by: Thomas Paul ]
 
Ranch Hand
Posts: 34
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
An overloaded method is just a method with the same name but with different arguments. There is no inheritance here.
Only overriden methods may not throw a checked exception that is not thrown by the corresponding method in the superclass.
 
reply
    Bookmark Topic Watch Topic
  • New Topic