Bird
0
0

Which of the following is the correct syntax to inherit class Vehicle in C#?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Inheritance
Which of the following is the correct syntax to inherit class Vehicle in C#?
Aclass Car inherits Vehicle {}
Bclass Car : Vehicle {}
Cclass Car extends Vehicle {}
Dclass Car -> Vehicle {}
Step-by-Step Solution
Solution:
  1. Step 1: Recall C# inheritance syntax

    In C#, a class inherits another using a colon ':' followed by the base class name.
  2. Step 2: Check each option

    class Car : Vehicle {} uses the correct syntax 'class Car : Vehicle {}'. Other options use incorrect keywords or symbols.
  3. Final Answer:

    class Car : Vehicle {} -> Option B
  4. Quick Check:

    C# inheritance syntax = Colon ':' [OK]
Quick Trick: Use ':' to inherit a class in C# [OK]
Common Mistakes:
MISTAKES
  • Using 'inherits' keyword instead of ':'
  • Using 'extends' like in Java
  • Using arrows or other symbols incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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