Page 237 - CA_Blue( J )_Class10
P. 237

Explanation: Here, the array "array2[]" changes after the copyelement(array1, array2) method is called from the
                 main() method, though the method does not return any value. Thus, we can say copyelement(array1, array2) is an
                 impure method.


                     10.9 METHOD OVERLOADING
                 Polymorphism is one of the features of object-oriented programming language. It means that a method can be used
                 for multiple purpose. To implement the concept of polymorphism, method overloading is used.

                 Method overloading is the process of creating different methods with same name and different number of parameters
                 or different data types of the parameters. Method overloading is a type of static binding. This is because at the time of
                 compilation, it is decided that which method is to be called. Let us take the following program:

                                 To calculate the area of a square, rectangle and circle using method overloading. The name of
                  Program 5
                                 the method is area.
                                 1. Area of Square: s 2
                                 2. Area of Rectangle: l x b
                                 3. Area of Circle: 22/7*r 2



                   1  class overloading
                   2  {
                   3      void area (int s)

                   4      {

                   5          int a = s*s;
                   6          System.out.println("Area of Square : "+a);

                   7      }
                   8      void area (int l , int b)

                   9      {
                  10          int a = l * b;



                                                                                                                       235
                                                                                                 User-defined Methods   235
   232   233   234   235   236   237   238   239   240   241   242