examples of Method overloading in java programming


What is meant by Overloading?

Answer: Method overloading happens for different classes or within the same class.

For method overloading, sub-class method should satisfy the below conditions with the Super-class method (or) methods in the same class itself:

  • Same method name
  • Different argument types
  • There may be different return types


public class Manipulation{ //Super class
public void add(String name){ //String parameter
Public class Addition extends Manipulation(){
Public void add(){//No Parameter
Public void add(int a){ //integer parameter
Public static void main(String args[]){
Addition addition = new Addition();

Here the add() method has different parameters in the Addition class is overloaded in the same class as with the super-class.

Note: Polymorphism is not applicable for method overloading.

All Contributions

total contributions (0)

New to examplegeek.com?

Join us