Vidyalelo
Python · Q72

Concept of Object Oriented Programs in Python

Programming · Python · question 72

Q72

What will be the output of the following Python code? class Test: def __init__(self): self.x = 0 class Derived_Test(Test): def __init__(self): self.y = 1 def main(): b = Derived_Test() print(b.x,b.y) main()

A.
0 1
B.
0 0
C.
Error because class B inherits A but variable x isn't inherited
Answer
D.
Error because when object is created, argument must be passed like Derived_Test(1)

Answer: Option C

Solution

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