Sail E0 Webinar
Question
What is the output of the following piece of code?class Demo:    def __init__(self):        self.x = 1    def change(self):        self.x = 10class Demo_derived(Demo):    def change(self):        self.x=self.x+1        return self.xdef main():    obj = Demo_derived()    print(obj.change()) main()
Options:
A .  11
B .  2
C .  1
D .  An exception is thrown
Answer: Option D


The derived class method change() overrides the base class method.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers