Computer Science, asked by VARundepSINgh, 1 year ago

Write Down A Java Program to calculate the area of Circle, Rectangle and Square using Function Overloading Method

Answers

Answered by altariqmarine655
0

Answer:

This is a Java Program to Find Area of Square, Rectangle and Circle using Method Overloading.

We declare three methods of same name but with different number of arguments or with different data types. Now when we call these methods using objects, corresponding methods will be called as per the number of arguments or their datatypes.

Here is the source code of the Java Program to Find Area of Square, Rectangle and Circle using Method Overloading. The Java program is successfully compiled and run on a Windows system.

Explanation:

Answered by niju53
1

Class Overload {

double volume(float l, float w, float h) {

return l * w * h;

}

double volume(float l) {

return l * l * l;

}

double volume(float r, float h) {

return 3.1416 * r * r * h;

}

}

public class MethodOverloading {

public static void main(String args[]) {

Overload overload = new Overload();

double rectangleBox = overload.volume(5, 8, 9);

System.out.println("Volume of rectangular box is " + rectangleBox);

System.out.println("");

double cube = overload.volume(5);

System.out.println("Volume of cube is " + cube);

System.out.println("");

double cylinder = overload.volume(6, 12);

System.out.println("Volume of cylinder is " + cylinder);

}

}

Similar questions