Page 37 - C++
P. 37

following it. Also, write the maximum and the minimum values that can be assigned to
                      the variable Y.









                      i) 0 : 0
                      ii) 1 : 6

                      iii) 2 : 4
                      iv) 0 : 3

               Ans    i) and iv) are the possible output(s)

                      Minimum value that can be assigned to Y = 0
                      Maximum value assigned to Y = 3

                      ( ½ mark for each correct possible output)
                      ( ½ mark for each correct possible minimum and maximum value)

        Q2     (a)    Explain operator overloading with the help of an example.                                     2

               Ans    The feature where an operator can be used in different forms is known as Operator
                      Overloading. It is one of the methods to implement polymorphism.

                      '+' operator behaves differently with different data types. With integers it adds the two
                      numbers and with strings it concatenates or joins two strings.
                       For example: Print 8+9 will give 17 and Print "Python" + "programming" will give the
                      output as Python programming.


                      (2 marks for correct explanation using an example)
                      (1 mark for only writing a definition)

               (b)    Observe the following Python code and answer the questions (i) and (ii):



















               (i)    How is data member „count‟ different from data member „Author‟?                               1

               Ans    Data member „count‟is a Class attribute whereas the data member „Author‟ is an

                                                        Page No. 20
   32   33   34   35   36   37   38   39   40   41   42