Page 250 - Cs_withBlue_J_C11_Flipbook
P. 250

Let’s Revisit


                    ♦ Methods are the block of statements in a program that performs a specific task and can be reused as and whenever
                   required. They are also called Functions.
                    ♦ The different parts  of methods are: Method Header, Signature, Access specifier, Return type and statement, method name,
                   parameter list, and Body of the method.
                    ♦ The value passed onto the method during the method call is known as the Actual Parameter and the parameter that
                   receives the value is known as the Formal Parameter.
                    ♦ There are two different ways of calling a method. They are pass by value and pass by reference.
                    ♦ Methods that do not change the values that are passed to it, are known as Pure Methods. They are also called Accessors.
                    ♦ Impure Methods are known as mutators and cause a change in the state of an object.
                    ♦ More than one method having the same name in a class is known as Method Overloading.
                    ♦ A class consists of characteristics and behaviour which are used to create objects.
                    ♦ The three access specifiers are: Public, Protected and Private. They are also known as Visibility modes.
                    ♦ External Wrappers are brackets that encapsulate the whole class. It contains the word class and the class name.
                    ♦ Whatever is in the braces after the class name, is the Internal Wrapper and contains the Instance variable, Class variable,
                   Local variable, Constructor and Member Methods.
                    ♦ The ‘new’ operator is used to create an object or an array as it allocates space in memory for storing data members of the
                   object or array elements.
                    ♦ The ’this’ operator is required to use the object of the class from the member method from the same class.
                    ♦ A constructor is a member function having the same name as that of a class and used to initialise the instance variables of
                   the objects that are created.




                                                           MIND DRILL




                   Solved Questions



              A.  Tick ( ) the correct answer:
                  1.  Why are methods useful?
                    a.  They reduce the size of the coding.         b.  They occupy less space in memory.
                    c.  They reduce the burden of debugging a long program.     d.  All of these
                  2.  What is the first line of any method definition called?
                    a.  Method footer                               b.  Method header
                    c.  Signature                                   d.  None of these
                  3.  Which of the following is the identification of the method that uses a method name and the different parameters which are
                    known as arguments?
                    a.  Access specifier                            b.  Method Signature
                    c.  Both a and b                                d.  None of  these
                  4.  Which of the following keywords allows the methods to be assessed by the same class only?
                    a.  Public                                      b.  Protected
                    c.  Default                                     d.  Private
                  5.  Which of the following statements sends back a value from the method to the caller program?
                    a.  Protected                                   b.  Return
                    c.  Parameter                                   d.  Body of the loop
                  6.  Where is the actual parameter defined?
                    a.   Calling program                            b.  Called program
                    c.  Pass by value                               d.  Pass by reference


                248248  Touchpad Computer Science-XI
   245   246   247   248   249   250   251   252   253   254   255