x

Java – Method Overloading

PREV     NEXT

Java Method Overloading:


  • If a class contains two or more methods with the same name, it is called JAVA method overloading.
  • It is used to achieve static polymorphism.
  • Binding of the method to its method call, is done in the compile time itself and hence it is called static binding or early binding.
  • The overloaded methods can differ by the number of arguments or argument type or sequence of the arguments.
  • The overloading method can be present in the same class or in subclasses of current class also.
    The difference should be only in the types and count of parameters, not in the method return types.

Example:


Output:

Addition of the 2 numbers is:12

Addition of the 2 numbers is:9.2

Addition of the 3 numbers is:15

PREV     NEXT



Like it? Please Spread the word!