Bird
Raised Fist0

Which of the following is the correct syntax to define a class Child that inherits from two parent classes Parent1 and Parent2?

easy📝 Syntax Q12 of Q15
Python - Multiple Inheritance and Method Resolution
Which of the following is the correct syntax to define a class Child that inherits from two parent classes Parent1 and Parent2?
Aclass Child : Parent1, Parent2
Bclass Child inherits Parent1, Parent2:
Cclass Child -> Parent1, Parent2:
Dclass Child(Parent1, Parent2):
Step-by-Step Solution
Solution:
  1. Step 1: Recall Python class inheritance syntax

    In Python, parent classes are listed inside parentheses after the class name.
  2. Step 2: Identify correct syntax for multiple inheritance

    Multiple parents are separated by commas inside the parentheses.
  3. Final Answer:

    class Child(Parent1, Parent2): -> Option D
  4. Quick Check:

    Parents in parentheses, comma separated [OK]
Quick Trick: Use parentheses with commas for multiple parents [OK]
Common Mistakes:
MISTAKES
  • Using 'inherits' keyword (not Python syntax)
  • Using colon instead of parentheses
  • Using arrow '->' which is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes