calculate area of rectangle using default constructor in java

Solutions on MaxInterview for calculate area of rectangle using default constructor in java by the best coders in the world

showing results for - "calculate area of rectangle using default constructor in java"
Salomé
26 Mar 2020
1import java.util.*;
2class RectangleShape 
3{
4   int area, length, breadth; 
5   RectangleShape() 
6   { 
7      length = 50; 
8      breadth = 20; 
9   } 
10   void getArea() 
11   { 
12      area = length * breadth; 
13      System.out.println("Area of Rectangle : " + area); 
14   }  
15}
16public class RectangleAreaConstructor
17{
18   public static void main(String[] args) 
19   {
20      RectangleShape rs = new RectangleShape(); 
21      rs.getArea();
22   }
23}