Page 677 - Computer science 868 Class 12
P. 677

Question 10.                                                                                          [5]
                 A super class Circle has been defined to calculate the area of a circle. Define a subclass Volume to calculate the volume of a cylinder.
                 The details of the members of both the classes are given below:
                 Class name                                    :  Circle
                 Data members/instance variables:
                 radius                                        :  to store the radius in decimals
                 area                                          :  to store the area of a circle
                 Methods/Member functions:
                 Circle( ... )                                 :  parameterised constructor to assign values to the data members
                                                                                          2
                 void cal_area()                               :  calculates the area of a circle (πr )
                 void display( )                               :  to display the area of the circle
                 Class name                                    :  Volume
                 Data members/instance variables:
                 height                                        :  to store the height of the cylinder in decimals
                 volume                                        :  to store the volume of the cylinder in decimals
                 Methods/Member functions:
                 Volume( ... )                                 :   parameterised constructor to assign values to the data members of both
                                                                 the classes
                 double calculate( )                           :   to calculate and return the volume of the cylinder using the formula (πr h)
                                                                                                                       2
                                                                 where, r is the radius and h is the height
                 void display( )                               :  to display the area of a circle and volume of a cylinder
                 Assume that the super class Circle has been defined. Using the concept of inheritance, specify the class Volume giving the details of the
                 constructor(...), double calculate( ) and void display( ).
                 The super class, main function and algorithm need NOT be written.

                 Question 11.
                 (i)  With the help of an example, briefly explain the constant factor in time complexity.             [2]
                 (ii)  Answer the following questions from the diagram of a Binary Tree given below:
                                                                   A


                                                             B           F


                                                         D                  G


                                                                         E     H

                      (a)  Name the external nodes of the right sub tree.                                              [1]
                     (b)  State the size and depth of the tree.                                                        [1]
                      (c)  Write the post-order traversal of the above tree structure.                                 [1]



















                                                                                                                       675
                                                                                                        Sample Paper   675
   672   673   674   675   676   677   678   679   680   681   682