by Dinesh Thakur Category: Classes

 

import java.io.*;;

        class Rectangle
           {
               int l,b,a;
               Rectangle(int x, int y)
                  {
                     l = x;
                     b = y;
                  }
                    void GetArea()
                      {
                        a=l*b;
                        System.out.println("Area of Rectangle is : "+a);
                      }
           } 
                       class RectangleParameterisedConstructor
                         {
                             public static void main(String args[])
                             throws IOException
                              {
                                BufferedReader  Br = new BufferedReader(new InputStreamReader(System.in));
                                  String lb;
                                  int Length,Breadth;
                                  System.out.println("Enter Length and Breadth");
                                  lb=Br.readLine();
                                  Length=Integer.parseInt(lb);
                                  lb=Br.readLine();
                                  Breadth=Integer.parseInt(lb);
                                  Rectangle Rect = new Rectangle(Length,Breadth);
                                  Rect.GetArea();
                              }
                        }

Area of Rectangle using Parameterised Constructor

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article