Page 465 - CA_Blue( J )_Class10
P. 465

37              rectangle ob3= new rectangle(ob2);       // creation of object ob3
                  38              ob1.calculate();           // Invoking functions

                  39              ob2.calculate();
                  40              ob3.calculate();

                  41              System.out.println("Calling Non-Parameterized Constructor");
                  42              ob1.display();

                  43              System.out.println("Calling Parameterized Constructor");
                  44              ob2.display();

                  45              System.out.println("Calling Copy Constructor");
                  46              ob3.display();

                  47          }               // close of main()
                  48      }               // close of class

                 Output
                 Calling Non-Parameterized Constructor
                 Area 32 Perimeter 24
                 -------------------------

                 Calling Parameterized Constructor
                 Area 48 Perimeter 28
                 -------------------------
                 Calling Copy Constructor
                 Area 48 Perimeter 28
                 -------------------------
                                                            Variable Description
                   NAME       DATATYPE                                     DESCRIPTION
                  l          int          Instance Variable to store length
                  b          int          Instance Variable to store breadth

                  a          int          Instance Variable to store area
                  p          int          Instance Variable to store perimeter
                  l1         int          Formal Parameter to store length
                  b1         int          Formal Parameter to store breadth


                     PROGRAMS ON ARRAYS

                 (a)  Programs based on accessing the elements of an array.

                               Write a program to accept "n" numbers into an array and then calculate the sum of even numbers
                  Program 9
                               present in odd positions.



                   1      import java.util.*;         //importing package "util"



                                                                                                                       463
                                                                                                   Internal Assessment  463
   460   461   462   463   464   465   466   467   468   469   470