Created
August 19, 2022 11:33
-
-
Save RahulKirtoniya/61370f75d8ae45e131143bc58ec15408 to your computer and use it in GitHub Desktop.
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. The program output is also shown below.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Internshalaques { | |
void area(float x) | |
{ | |
System.out.println("the area of the square is "+Math.pow(x,2)+" sq units"); | |
} | |
void area(float x, float y) | |
{ | |
System.out.println("the area of the rectangle is "+x*y+" sq units"); | |
} | |
void area(double x) { | |
double z = 3.14 * x * x; | |
System.out.println("the area of the circle is "+z+" sq units"); | |
} | |
} | |
class overload | |
{ | |
public static void main(String[] args) { | |
{ | |
Internshalaques ob = new Internshalaques(); | |
ob.area(5); | |
ob.area(11,12); | |
ob.area(2.5); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment