• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

overriding and overloading

 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • 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?
 
chi Lin
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • 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?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • 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 ]
 
Francois Roland
Ranch Hand
Posts: 34
Java
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic