Bird
0
0

Which of the following is the correct syntax to define a class C that inherits from classes A and B in Python?

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

    Python uses parentheses after class name to list base classes separated by commas.
  2. Step 2: Check each option

    Only class C(A, B): pass uses correct syntax: class C(A, B): pass
  3. Final Answer:

    class C(A, B): pass -> Option D
  4. Quick Check:

    Inheritance syntax = class C(A, B): [OK]
Quick Trick: Use parentheses with base classes for inheritance [OK]
Common Mistakes:
  • Using 'inherits' keyword
  • Wrong punctuation in class definition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes