ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
class A:
    def __init__(self):
        print("A", end=" ")
class B(A):
    def __init__(self):
        print("B", end=" ")
class C(B):
    pass
C()
print(C.__init__ is B.__init__, C.__mro__[1].__name__)
  1. A. A B True B
  2. B. B A True B
  3. C. B True B
  4. D. B False A

Correct answer: C. B True B

C inherits B.__init__, which does not call super(), so A.__init__ never runs. The attribute lookup returns the very same function object, and C's MRO is C, B, A, object.

More Python Programming questions

Exams that ask this topic