Write a program to calculate the area of rectangle using the concept of Class and Object in Java?
class rect
{
int l,b;
public rect(int lt,int br)
{
l=lt;
b=br;
}
public void area()
{
int ar=l*b;
System.out.print("Area of Rectangle
having length 6 and breadth 5 = "+ar);
}
}
class m
{
public static void main(String args[])
{
rect obj=new rect(6,5);
obj.area();
}
}
Comments
Post a Comment