Page 257 - C++
P. 257

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



             2     (a)    List four characteristics of Object Oriented programming.                            2
                   Ans    Encapsulation
                          Data Hiding
                          Abstraction
                          Inheritance
                          Polymorphism

                          ( ½ mark for each characteristic upto four characteristics)
                   (b)    class Test:                                                                          2
                            rollno=1

                            marks=75
                            def __init__(self,r,m):                                #function 1
                                 self.rollno=r
                                 self.marks=m
                            def assign(self,r,m):                                  #function 2
                                 rollno = n
                                 marks = m

                            def check(self):                                          #function 3
                                 print self.rollno,self.marks
                            print rollno,marks
                          (i) In the above class definition, both the functions - function 1 as well as function
                             2 have similar definition. How are they different in execution?
                          (ii) Write statements to execute function 1 and function 2.
                   Ans    i)   Function 1 is the constructor which gets executed automatically as soon as
                               the object of the class is created. Function 2 is a member function which has
                               to be called to assign the values to rollno and marks.

                          ii)  Function 1      ​E1=Test(1,95) # Any values in the parameter
                                 Function 2      ​E1.assign(1,95) # Any values in the parameter

                          (1 mark for correct difference)
                          ( ½ mark for each statement for executing Function 1 and function 2)

                   (c)    Define a class RING in Python with following specifications                          4
                          Instance Attributes
                          - RingID  # Numeric value with a default value 101
                          - Radius  # Numeric value with a default value 10
                          - Area        # Numeric value
                          Methods:
                          - AreaCal() # Method to calculate Area as
                                               # 3.14*Radius*Radius
                          - NewRing() # Method to allow user to enter values of
                                           # RingID and Radius. It should also
                                           # Call AreaCal Method
                          - ViewRing() # Method to display all the Attributes

                                                     Page #16 of 28
   252   253   254   255   256   257   258   259   260   261   262