What is method "Overloading" in object-oriented programming (OOP) ?

Method or function overloading allows a method with the same name to be declared more than once given that they have different input parameters.
For example, there is a method to calculate the area of shapes. There are different shapes such as circles and rectangles. In these two cases, if someone calls the function calculateArea, the result should be correct for the given shape, regardless of whether the shape is a circle or a rectangle. The declaration of this in a programming language in shown below:
Rectangle: calculateArea(double length, double width
Circle: calculateArea(double radius)
A great advantage of method overloading is that it allows a programmer to use the function appropriately without having to know the inner-workings of that method. 

AS

Related Computing A Level answers

All answers ▸

In programming, some languages are compiled and others are interpreted. Define the difference between the two.


What are the different development methodologies and what are their advantages and disadvantages?


What are the main differences between different loops when it comes to coding ?


Describe what you understand by abstraction, and how it is relevant to software engineering.