ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
class Base:
    def __init__(self):
        print("Base", end=" ")
class L(Base):
    def __init__(self):
        print("L", end=" ")
        super().__init__()
class R(Base):
    def __init__(self):
        print("R", end=" ")
class M(L, R):
    pass
M()
  1. A. L Base
  2. B. L R Base
  3. C. L R
  4. D. L Base R

Correct answer: C. L R

M's MRO is M, L, R, Base. L's super().__init__() calls the NEXT class in M's MRO, which is R, not Base. R does not call super(), so Base.__init__ never runs.

More Python Programming questions

Exams that ask this topic