A

Admin • 832.27K Points
Coach

Q. What is output of the following?

Code:
class A:
def __init__(self):
self.name = 'A'

class B(A):
def __init__(self):
super().__init__()
self.name += 'B'

b = B()
print(b.name)
  • (A) B
  • (B) A
  • (C) AB
  • (D) Error
  • Correct Answer - Option(C)
  • Views: 23
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

super() calls A’s __init__, then 'B' is appended to name.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.