← 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())
- A.A
- B.B
- C.C
- 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 →