Bird
0
0

Which of the following is the correct syntax to declare a class Car implementing interfaces IMovable and IEngine?

easy📝 Syntax Q12 of 15
C Sharp (C#) - Interfaces

Which of the following is the correct syntax to declare a class Car implementing interfaces IMovable and IEngine?

?
Apublic class Car : IMovable, IEngine { }
Bpublic class Car implements IMovable, IEngine { }
Cpublic class Car inherits IMovable, IEngine { }
Dpublic class Car : IMovable & IEngine { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall C# interface syntax

    In C#, a class uses a colon ':' followed by interface names separated by commas.
  2. Step 2: Check each option

    public class Car : IMovable, IEngine { } uses ':' and commas correctly. Options B and C use wrong keywords. public class Car : IMovable & IEngine { } uses '&' which is invalid.
  3. Final Answer:

    public class Car : IMovable, IEngine { } -> Option A
  4. Quick Check:

    Interfaces listed after ':' separated by commas [OK]
Quick Trick: Use ':' and commas to list interfaces after class name [OK]
Common Mistakes:
MISTAKES
  • Using 'implements' keyword (Java style)
  • Using '&' instead of commas
  • Using 'inherits' keyword incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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