What is Method Overloading?

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

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

  • Same method name
  • Different argument type
  • May have different return types

Example: 

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(); 
        addition.add(); 
    }
}

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

Note: Polymorphism is not applicable for method overloading.

Top 50+ Java Interview Questions with Answers

We covered nearly 50 + primary Java interview questions in this tutorial for fresh and experienced candidates.  Q.1- What is… Read More

4 years ago