Bird
0
0

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

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

    Python uses parentheses with comma-separated parent classes.
  2. Step 2: Match syntax with options

    class Child(Parent1, Parent2): pass correctly shows class Child inheriting from Parent1 and Parent2 using parentheses and comma.
  3. Final Answer:

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

    Multiple inheritance syntax = Parent classes in parentheses separated by commas [OK]
Quick Trick: Use commas inside parentheses for multiple inheritance [OK]
Common Mistakes:
  • Using incorrect keywords like 'inherits'
  • Using '&' instead of comma
  • Not using parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes