Program to find area of rectangle using inheritance in java
// Program to find area of rectangle using inheritance in java
class RectangleDimension
{
int length;
int breadth;
}
class Rectangle extends RectangleDimension
{
int area;
void findArea()
{
area = length * breadth;
}
}
public class AreaOfRectangleUsingInheritance
{
public static void main(String[] args)
{
Rectangle obj = new Rectangle();
obj.length = 50;
obj.breadth = 20;
obj.findArea();
int area = obj.length * obj.breadth;
System.out.println("Area of rectangle is: " + area);
}
}