Page 258 - C++
P. 258

CBSE AISSCE 2016-2017 Marking Scheme for Computer Science
                                         (Sub Code: 083 Paper Code 91/1 Delhi)



                   Ans    class RING:​  ​# OR  class RING( ): ​OR class RING(Object):

                            def __init__(self):
                              self.RingID=101
                              self.Radius=10
                              self.Area=0

                            def AreaCal(self):
                              self.Area=3.14*self.Radius*self.Radius

                            def NewRing(self):
                              self.RingID=input("Enter RingID")
                              self.Radius=input("Enter radius")
                              self.AreaCal()   # OR AreaCal(self)
                            def ViewRing(self):
                              print self.RingID
                              print self.Radius
                              print self.Area

                          (½ Mark for correct syntax for class header)
                          (½ Mark for correct declaration of instance attributes)
                          (1 Mark for correct definition of AreaCal() function)
                          (1 Mark for correct definition of NewRing() with invocation of AreaCal( ))
                          (1 Mark for correct definition of ViewRing())
                          NOTE:
                          Deduct ½ Mark if AreaCal() is not invoked properly inside NewRing() function
                   (d)    Differentiate between static and dynamic binding in Python? Give suitable                             2
                          examples of each.

                   Ans    Static Binding: It allows linking of function call to the function definition during
                          compilation of the program.

                          Dynamic Binding: It allows linking of a function during run time. That means the
                          code of the function that is to be linked with function call is unknown until it is
                          executed. Dynamic binding of functions makes the programs more flexible.

                          (1 mark for each correct explanation of static and dynamic binding)
                          OR
                          (1 for each correct example of static and dynamic binding)
                   (e)    Write   two   methods    in   Python   using   concept   of   Function   Overloading  2
                          (Polymorphism) to perform the following operations:
                          (i) A function having one argument as side, to calculate Area of Square as
                              side*side
                          (ii) A function having two arguments as Length and Breadth, to calculate Area of
                              Rectangle as Length*Breadth.
                   Ans    def Area(side):
                            print side*side
                          def Area(length,breadth):
                            print length*breadth


                                                     Page #17 of 28
   253   254   255   256   257   258   259   260   261   262   263