PROGRAM TO IMPLEMENT FUNCTION OVERLOADING

//PROGRAM TO IMPLEMENT FUNCTION OVERLOADING
class Rectangle
{
int length,breadth;
Rectangle( )
{
length=10;
breadth=5;
}
Rectangle(int l,int b)
{
length=l;
breadth=b;
}
int area( )
{
return(length*breadth);
}
public static void main(String args[ ])
{
Rectangle r1=new Rectangle( );
Rectangle r2=new Rectangle(20,5);
System.out.println(“Area with length= 10 and breadth= 5 is = “+r1.area( ));
System.out.println(“Area with length =20 and breadth= 5 is  =”+r2.area( ));
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *