Professional Documents
Culture Documents
Exp 5
Exp 5
METHOD OVERLOADING
AIM
Write a Java program to find the area of square, rectangle and triangle using method overloading.
COURSE OUTCOME
CO1 Develop programs using Java class & object
MODULE OUTCOME
M1.05 Implement programs using method overloading
PROGRAM
import java.io.*;
class Shape
{
double area;
void area(float x)
{
area = x * x;
}
void display()
{
System.out.println("Area is "+area);
}
}
public class Exp4
{
public static void main(String[] args) throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
float a,b,c;
Shape S=new Shape();
OBSERVATIONS
Enter side of square5
Area is 25.0
Enter length and breadth of reactanble 10 5
Area is 50.0
Enter three sides of the triangle 2 3 4
Area is 2.9047375096555625
RESULT
Studies method overloading in Java.