A

Admin • 833.24K Points
Coach

Q. What is the output of this code?

Code:
class A:
def __init__(self):
print("A init")

class B(A):
pass

b = B()
  • (A) No output
  • (B) A init
  • (C) Error
  • (D) B init
  • Correct Answer - Option(B)
  • Views: 28
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

B inherits A and doesn't override __init__, so A’s constructor is used.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.