Bird
0
0

Which of the following is the correct syntax to express an Is-a relationship in C#?

easy📝 Syntax Q12 of 15
C Sharp (C#) - Inheritance
Which of the following is the correct syntax to express an Is-a relationship in C#?
Aclass Dog inherits Animal {}
Bclass Dog extends Animal {}
Cclass Dog : Animal {}
Dclass Dog -> Animal {}
Step-by-Step Solution
Solution:
  1. Step 1: Recall C# inheritance syntax

    In C#, the colon (:) symbol is used to indicate inheritance.
  2. Step 2: Compare options

    class Dog : Animal {} uses the correct syntax 'class Dog : Animal {}'. Others use incorrect keywords or symbols.
  3. Final Answer:

    class Dog : Animal {} -> Option C
  4. Quick Check:

    C# inheritance uses ':' = C [OK]
Quick Trick: Use ':' to inherit in C# classes [OK]
Common Mistakes:
MISTAKES
  • Using 'inherits' keyword (not valid in C#)
  • Using 'extends' (Java syntax)
  • Using arrows or other symbols

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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