/* Single Inhetitance To Find Area Of Rectangle */
class Dimensions
{
int length;
int breadth;
}
class Rectangle extends Dimensions
{
int a;
void area()
{
a = length * breadth;
}
}
class Area
{
public static void main(String args[])
{
Rectangle Rect = new Rectangle();
Rect.length = 7;
Rect.breadth = 16;
Rect.area();
System.out.println("The Area of rectangle of length "
+Rect.length+" and breadth "+Rect.breadth+" is "+Rect.a);
}
}
/* Output *
The Area of rectangle of length 7 and breadth 16 is 112 */
0 comments:
Post a Comment