What is the output of the following Python code snippet?
class A:
def __init__(self): print('A init')
class B(A):
def __init__(self): print('B init')
B()
-
A
A init
-
B
Error
-
C
B init
Correct answer
-
D
None
Explanation
A subclass __init__ without super().__init__() does not run the parent's __init__.
Doubts & discussion
Not sure why the answer is C? Ask here and get an explanation.
Ask a doubt about this MCQ