Bird
Raised Fist0

Consider this scenario: You want to create a class hierarchy where a class Car is a Vehicle and also implements an interface IEngine. How does the Is-a relationship apply here?

hard🚀 Application Q9 of Q15
C Sharp (C#) - Inheritance
Consider this scenario: You want to create a class hierarchy where a class Car is a Vehicle and also implements an interface IEngine. How does the Is-a relationship apply here?
ACar Is-a Vehicle and Car Is-a IEngine by inheritance and interface implementation.
BCar Is-a Vehicle but cannot be IEngine because interfaces are unrelated.
CCar Is-a IEngine only, Vehicle is unrelated.
DCar cannot inherit and implement at the same time.
Step-by-Step Solution
Solution:
  1. Step 1: Understand class and interface Is-a relationships

    Class inheritance means Car Is-a Vehicle; implementing interface means Car Is-a IEngine.
  2. Step 2: Confirm multiple inheritance rules in C#

    C# allows single class inheritance and multiple interface implementations.
  3. Final Answer:

    Car Is-a Vehicle and Car Is-a IEngine by inheritance and interface implementation. -> Option A
  4. Quick Check:

    Class inherits + implements = multiple Is-a [OK]
Quick Trick: Class can inherit one class and implement many interfaces [OK]
Common Mistakes:
MISTAKES
  • Thinking interfaces are unrelated to Is-a
  • Believing multiple inheritance of classes is allowed
  • Confusing interface implementation with composition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes