Methods overloading: – Like other programming language, java also private facility for method overloading. It is possible to create methods that have the same name, but different parameter list and/or different definition. This is called method overloading. Method overloading is used when objects are required to perform different classes with different input parameters. When we call a method in an object, java matches up the method name first and then the number and type of parameters to decide which of one of definition to execute. This process is called polymorphism.

To create an overloaded method, all we have to do is to provide several different method definitions in the class, all with the same name but with different parameters. This different may either we in the number of type of arguments. That is, each parameter list should be unique. Not that the method’s return type does not play any role form method overloaded.

Advertisements