Vidyalelo
Python · Q37

Concept of Object Oriented Programs in Python

Programming · Python · question 37

Q37

What will be the output of the following Python code? class A: def __init__(self): self._x = 5 class B(A): def display(self): print(self._x) def main(): obj = B() obj.display() main()

A.
Error, invalid syntax for object declaration
B.
Nothing is printed
C.
5
Answer
D.
Error, private class member can't be accessed in a subclass

Answer: Option C

Solution

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