Overloading

In OOPS, Overloading is another useful aspect which has many benefits when to use properly.
As we know that a JAVA program usually consists of Classes and each class has two thing i.e the data members which describe the properties or characteristics of an object and other are methods which describes the actions or behavior of the object.

Method overloading is way to declare two or more methods or constructors  which have same name but different signature. i.e


  • IN OVERLOADED METHODS HAVE SAME NAME BUT DIFFERENT SIGNATURE.
  • THERE SIGNATURE DIFFERS IN DATA TYPES OR NUMBER OF ARGUMENTS IN THEIR SIGNATURE.


Below examples explains the concept of Method overloading






In above example we have a class CalcArea which has two methods with same name of calculate_area which has different number of arguments.

One is calculating the are of a Triangle and other is calculating the area of Square.
This is called method overloading.