Bird
0
0

Which of the following is the correct way to declare a simple class named Car in C#?

easy📝 Syntax Q12 of 15
C Sharp (C#) - Classes and Objects
Which of the following is the correct way to declare a simple class named Car in C#?
Aclass Car { }
BCar class { }
Cclass = Car { }
Dclass Car() { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall C# class declaration syntax

    In C#, a class is declared using the keyword class followed by the class name and curly braces.
  2. Step 2: Check each option

    class Car { } matches the correct syntax: class Car { }. Others have syntax errors.
  3. Final Answer:

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

    Correct class syntax [OK]
Quick Trick: Use 'class ClassName { }' to declare classes [OK]
Common Mistakes:
MISTAKES
  • Putting parentheses after class name
  • Swapping 'class' and class name
  • Using '=' sign in declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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