Bird
Raised Fist0

Which statement about method resolution order (MRO) in Python inheritance is true?

hard🧠 Conceptual Q10 of Q15
Python - Inheritance and Code Reuse
Which statement about method resolution order (MRO) in Python inheritance is true?
APython only uses the parent class methods, ignoring child methods.
BPython looks for methods in the child class first, then parent classes in order.
CPython randomly chooses which class method to use when multiple exist.
DPython requires explicit method calls to parent methods; otherwise, child methods are ignored.
Step-by-Step Solution
Solution:
  1. Step 1: Understand MRO basics

    Python searches for methods starting from the child class, then moves up the inheritance chain.
  2. Step 2: Evaluate options

    Python looks for methods in the child class first, then parent classes in order. correctly describes this search order.
  3. Final Answer:

    Python looks for methods in the child class first, then parent classes in order. -> Option B
  4. Quick Check:

    MRO = child first, then parents [OK]
Quick Trick: Python checks child methods before parent methods [OK]
Common Mistakes:
MISTAKES
  • Thinking parent methods override child methods
  • Believing method calls are random
  • Assuming explicit calls needed always

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes