Bird
Raised Fist0

You want to create a class SmartPhone that has features from both Camera and Phone classes. Which is the best reason to use multiple inheritance here?

hard🚀 Application Q15 of Q15
Python - Multiple Inheritance and Method Resolution
You want to create a class SmartPhone that has features from both Camera and Phone classes. Which is the best reason to use multiple inheritance here?
ATo make the phone run faster
BTo avoid creating any methods in SmartPhone
CTo combine camera and phone features without rewriting their code
DTo force Camera and Phone to share the same methods
Step-by-Step Solution
Solution:
  1. Step 1: Understand the goal of SmartPhone class

    SmartPhone needs to have both camera and phone abilities.
  2. Step 2: Recognize multiple inheritance benefit

    Using multiple inheritance lets SmartPhone reuse code from Camera and Phone classes without rewriting.
  3. Final Answer:

    To combine camera and phone features without rewriting their code -> Option C
  4. Quick Check:

    Multiple inheritance = reuse multiple parents' features [OK]
Quick Trick: Use multiple inheritance to reuse code from many classes [OK]
Common Mistakes:
MISTAKES
  • Thinking it improves speed
  • Believing it removes need for methods
  • Assuming it forces method sharing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes