Vidyalelo
Python · Q39

Concept of Object Oriented Programs in Python

Programming · Python · question 39

Q39

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

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

Answer: Option D

Solution

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