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

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart