πŸ“Š Python
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
πŸ’¬ Discuss
βœ… Correct Answer: (B) Error, private class member can’t be accessed in a subclass

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
216
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Tanmay
Publisher
πŸ“ˆ
92%
Success Rate