Vidyalelo
Python · Q24

Concept of Object Oriented Programs in Python

Programming · Python · question 24

Q24

What will be the output of the following Python code? class Demo: def __init__(self): self.x = 1 def change(self): self.x = 10 class Demo_derived(Demo): def change(self): self.x=self.x+1 return self.x def main(): obj = Demo_derived() print(obj.change()) main()

A.
11
B.
2
Answer
C.
1
D.
An exception is thrown

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board