Which of the following best illustrates the Is-a relationship in C#?
easy🧠 Conceptual Q1 of 15
C Sharp (C#) - Inheritance
Which of the following best illustrates the Is-a relationship in C#?
AA method returns a string value
BA class Car contains an Engine object
CA class Dog inherits from class Animal
DA variable stores an integer value
Step-by-Step Solution
Solution:
Step 1: Understand Is-a relationship
The Is-a relationship means one class is a subtype of another, typically via inheritance.
Step 2: Analyze options
A class Dog inherits from class Animal shows inheritance (Dog is an Animal), which is an Is-a relationship. A class Car contains an Engine object shows composition (has-a), not Is-a. Options C and D are unrelated to class relationships.
Final Answer:
A -> Option C
Quick Check:
Inheritance means Is-a [OK]
Quick Trick:Inheritance means Is-a relationship [OK]
Common Mistakes:
MISTAKES
Confusing Is-a with Has-a relationship
Thinking method return types define Is-a
Assuming variables imply inheritance
Master "Inheritance" in C Sharp (C#)
9 interactive learning modes - each teaches the same concept differently