Answers for "Program to find area of rectangle using inheritance in java"

1

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);
   }
}
Posted by: Guest on February-22-2021

Code answers related to "Program to find area of rectangle using inheritance in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language