Page 248 - CA_Blue( J )_Class10
P. 248

Answers
                   1.  function       2.  void          3.  Predefined methods   4.  private   5.  Method signature
                   6.  Return Statement   7.  Parameter List   8.  non-static   9.  Impure   10.  Method overloading


              C.  Answer the following questions:
                  1.  Define a method.
                Ans.  A method is a block of statements in a program which perform a specific task and can be reused as and whenever required. It is
                     also called function.
                  2.  What is the need for using a method?
                Ans.  Method is necessary to perform operations on the data members of a class. They reduce the size of a program and also reduce
                     the burden of debugging of programming code, as finding and correcting the errors becomes easy for programmer.
                  3.  What is the reason to use access specifier?
                Ans.  Since methods can be accessed by other classes, the same class, or other methods, we need to apply some restrictions  on the
                     accessibility of the methods. This is done by the access specifiers.
                  4.  What are the two forms of method?
                Ans.  The two forms of methods are:
                     1.  Predefined Methods                         2.  User-defined Methods
                  5.  What are user-defined methods?
                Ans.  A method written by the programmer according to his requirements is known as a "user-defined method." It helps a programmer
                     to write customised code according to the needs of a program.

                  6.  Write the difference between actual parameter and formal parameter.
                Ans.
                                    Actual Parameter                                Formal Parameter
                      The actual values are  passed directly  or through  The values  send by  the calling program  are  received in the
                      variables to the respective method at the time of calling  parameters described in the method.
                      the method.
                      It is defined in the calling program.       It is defined in the method.

                  7.  Write the two ways of invoking a method.
                Ans.  The two ways of invoking a method are:
                     1.  Pass by Value                              2.  Pass by Reference
                  8.  Write the difference between the static and non-static methods.
                Ans.                 Static Method                                  Non-Static Method

                      A  static  method  is  common  to  all  the  objects  of  the  It is an instance method which contain different values in different
                      class.                                      object of the same class.
                      The word static is written before the method name.  The word static in not written before the method name.

                  9.  Write the difference between pure method and impure method.
                Ans.                  Pure Method                                    Impure Method

                      A pure function does not change the state of an object. An impure function changes the state of an object.
                      It returns a value to the function from where it is called. It may or may not return a value to the function from where it is called.

                 10.  Define method overloading.
                Ans.  Method overloading is the process of creating different methods with same name and different number of parameters or
                     different data types of the parameters.







                246246  Touchpad Computer Applications-X
   243   244   245   246   247   248   249   250   251   252   253