Bird
Raised Fist0

Which of the following is true about extending a parent class method in Python?

easy🧠 Conceptual Q2 of Q15
Python - Inheritance and Code Reuse
Which of the following is true about extending a parent class method in Python?
AYou can call the parent method using <code>super()</code> and add extra code
BYou must always override the method without calling the parent
CYou cannot call the parent method once overridden
DThe child class method must have a different name
Step-by-Step Solution
Solution:
  1. Step 1: Understand method overriding and extension

    When overriding, you can still call the parent method to keep its behavior.

  2. Step 2: Recognize how super() helps

    super() allows calling the parent method inside the child method, then adding new code.

  3. Final Answer:

    You can call the parent method using super() and add extra code -> Option A
  4. Quick Check:

    Extending parent method = A [OK]
Quick Trick: Call super() inside child to extend parent method [OK]
Common Mistakes:
MISTAKES
  • Forgetting to call super() when extending
  • Thinking overriding means no parent call
  • Renaming methods unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes