Bird
Raised Fist0

Which of the following is the correct syntax to call a parent class method greet inside a child class method in Python?

easy📝 Syntax Q12 of Q15
Python - Inheritance and Code Reuse
Which of the following is the correct syntax to call a parent class method greet inside a child class method in Python?
Asuper().greet()
Bsuper.greet()
Cparent.greet()
Dself.super.greet()
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct super() syntax

    In Python, super() is a function and must be called with parentheses before accessing methods.
  2. Step 2: Identify correct method call

    The correct way to call the parent method is super().greet(), not super.greet() or others.
  3. Final Answer:

    super().greet() -> Option A
  4. Quick Check:

    super() needs parentheses = A [OK]
Quick Trick: Use parentheses with super() to call parent methods [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses after super
  • Using parent instead of super
  • Trying to access super as an attribute

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes