Answers for "Calculate area of rectangle using default constructor in java"

1

Calculate area of rectangle using default constructor in java

import java.util.*;
class RectangleShape 
{
   int area, length, breadth; 
   RectangleShape() 
   { 
      length = 50; 
      breadth = 20; 
   } 
   void getArea() 
   { 
      area = length * breadth; 
      System.out.println("Area of Rectangle : " + area); 
   }  
}
public class RectangleAreaConstructor
{
   public static void main(String[] args) 
   {
      RectangleShape rs = new RectangleShape(); 
      rs.getArea();
   }
}
Posted by: Guest on February-09-2021

Code answers related to "Calculate area of rectangle using default constructor in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language