Method Overloading

A method is a collection of statements that are grouped together to perform an operation. It is OOP analogue to the functions in procedural language.

Method syntax consist of two parts- a method header and a method body. The syntax of a method is as given below

Syntax –               modifier    return_Data_Type Method_Name(list of   parameters)

                                 {             // Method body;              }

Method overloading is a concept in Java which allows programmer to declare method with same name but different behavior. It is possible that method with same name co-exists in same class but they must have different method signature. If you have two or more methods with same name in a class with different method signature then it is called overloaded method. The method name along with the arguments constitute method signature. To create an overloaded method all we have to do is to change its signature, i.e. change either number of argument, type of argument or order of argument.

The process used to link which method or variable to be called as result of their reference in code is called binding. There are two possible methods of binding- Static and Dynamic. In case of the method overloading the static binding is used, i.e. binding occurs during compilation time. It is always useful to know that overloaded method are bonded using static binding while overridden methods are bonded during compile time.

 

About Vishnu Kishor