What will be the output of the following Python code? [code] class A: def __init__(self): self._x = 5 class B(A):

Man Ly

New member
What will be the output of the following Python code?
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
D. Error, private class member can’t be accessed in a subclass
 

Tìm kiếm

Back
Top