Bird
0
0

Why does Ruby use single inheritance instead of multiple inheritance?

easy📝 Conceptual Q11 of 15
Ruby - Inheritance
Why does Ruby use single inheritance instead of multiple inheritance?
ATo keep code simple and avoid conflicts between parent classes
BBecause Ruby does not support any form of inheritance
CTo allow a class to inherit from many classes at once
DTo make the language slower and more complex
Step-by-Step Solution
Solution:
  1. Step 1: Understand Ruby's inheritance model

    Ruby allows only one parent class for inheritance, which is called single inheritance.
  2. Step 2: Reason why single inheritance is chosen

    This design avoids conflicts that can happen when inheriting from multiple classes and keeps code easier to understand and maintain.
  3. Final Answer:

    To keep code simple and avoid conflicts between parent classes -> Option A
  4. Quick Check:

    Single inheritance avoids conflicts = D [OK]
Quick Trick: Single inheritance avoids confusion and keeps code clean [OK]
Common Mistakes:
  • Thinking Ruby supports multiple inheritance directly
  • Believing inheritance makes code slower
  • Confusing modules with classes in inheritance

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes