🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Inheritance, ABC and MRO: all 10 questions

Quiz: Inheritance, ABC and MRO · Question 3 of 10

What does this print? (code)

What does this print?

class A:
    def who(self): return "A"
class B(A):
    def who(self): return "B"
class C(A):
    def who(self): return "C"
class D(C, B):
    pass
print(D().who())
  1. A.A
  2. B.B
  3. C.C
  4. D.An error
Answer & explanation

Correct answer: C

C is listed first in class D(C, B), so it comes before B in the MRO.

Can you get the rest right without peeking?

Take the timed Quiz: Inheritance, ABC and MRO quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →