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()
Answer: Option D
Was this answer helpful ?
The derived class method change() overrides the base class method.
Was this answer helpful ?
More Questions on This Topic :
Question 1. Which function overloads the == operator? ....
Question 2. What is setattr() used for? ....
Submit Solution