Page 304 - CA_Blue( J )_Class10
P. 304

9      rectangle2 (rectangle2 r)
                10      {

                11         length = r.length;
                12           breadth=r.breadth;

                13      }
                14      void cal()

                15      {
                16         area = length * breadth;

                17         perimeter = 2*(length+breadth);
                18      }

                19
                20      void display ()

                21      {
                22          System.out.println("Area of Rectangle:" + area);

                23          System.out.println("Perimeter of Rectangle:" + perimeter);
                24      }
                25      public static void main ()

                26      {

                27          rectangle2 ob1 = new rectangle2 (5,4);
                28
                29         rectangle2 ob2 = new rectangle2(ob1);

                30         ob1.cal ();
                31         ob1.display();

                32         ob2.cal ();
                33         ob2.display();

                34      }
                35  }

              You will get the following output:



















                302302  Touchpad Computer Applications-X
   299   300   301   302   303   304   305   306   307   308   309