class
Rect
{
int length;
int breadth;
int area;
static int count;
Rect(int a,int b)
{
length = a;
breadth = b;
count++;
}
Rect()
{
length = 0;
breadth = 0;
count++;
}
void calc()
{
area = length * breadth;
}
void display()
{
System.out.println("Length
: " + length);
System.out.println("Breadth : " + breadth);
System.out.println("Area :
" + area);
}
}
class
Rect1
{
public static void main(String args[])
{
System.out.println("No of
object : " + Rect.count);
Rect r1 = new Rect(10,20);
r1.calc();
System.out.println("No of
object : " + Rect.count);
Rect r2 = new Rect();
r2.calc();
System.out.println("No of
object : " + Rect.count);
r1.display();
r2.display();
}
}
If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!
0 comments:
Have any question? Feel Free To Post Below: