Overloading

Categories: Java // Tags: , , .
Email this to someonePrint this pageShare on Google+0Share on Facebook0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Pin on Pinterest2Share on StumbleUpon0

Java Overloading

Overloaded method gives you an option to use the same method name in a class but with different argument.

Method overloading is a controversial language feature, especially in the context of Object Oriented languages, where its interaction with overriding may lead to confusing semantics. One of the main arguments against overloading is that it can be abused by assigning the same identity to conceptually different methods

Overloading Method Rules
There are some rules associated with overloaded method.

Overloaded methods

  • Must change the argument list
  • Can change the return type
  • Can change the access modifier(Broader)
  • Can declare new or broader checked exception
  • A method can be overloaded in Class or in SubClass.

Overloading Method Example

Invoking Overloaded Method
Out of several available overloaded method which method to invoke is based on the arguments.

First call will execute the first method and second will execute the second method.

Email this to someonePrint this pageShare on Google+0Share on Facebook0Tweet about this on TwitterShare on LinkedIn0Share on Reddit0Pin on Pinterest2Share on StumbleUpon0

About Team

Browse Archived Articles by Team