Examveda

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

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


Join The Discussion

Related Questions on Concept of Object Oriented Programs in Python