• Post Reply Bookmark Topic Watch Topic
  • New Topic

how the method overriding block the inheritence and how the method overloading does  RSS feed

 
ramakrishna chowdary
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi this is the rama krishna. i have some doubt regarding method overloading and method overriding ... and give the difference with an example for each one....
 
Divya Shastry
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In method overloading...two methods can have the same name but different signatures ( This includes the parameter types and the number of parameters but does not include the return type of the method)

In method overriding..the methods have the same signature.

The reason why overriding doesn't allow inheritance can be understood by the following example :



Once you run the code, you will notice that in the case of the over ridden methods, the super class method is not inherited !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!