Vidyalelo
Python · Q59

Concept of Object Oriented Programs in Python

Programming · Python · question 59

Q59

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): Test.__init__(self) self.y = 1 def main(): b = Derived_Test() print(b.x,b.y) main()

A.
Error because class B inherits A but variable x isn't inherited
B.
0 0
C.
0 1
Answer
D.
Error, the syntax of the invoking method is wrong

Answer: Option C

Solution

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