T

Tanmay • 2.43K Points
Master

Q. What will be the output of the following Python code?

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) Error, invalid syntax for object declaration
  • (B) Error, private class member can’t be accessed in a subclass
  • (C) NA
  • (D) NA
  • Correct Answer - Option(B)
  • Views: 177
  • Filed under category Python

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics