Vidyalelo
Python · Q46

Concept of Object Oriented Programs in Python

Programming · Python · question 46

Q46

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

A.
5
Answer
B.
Error, class member x has two values
C.
3
D.
Error, protected class member can't be accessed in a subclass

Answer: Option A

Solution

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