Bird
0
0

Which of the following is the correct syntax to declare a class named Person in C#?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Classes and Objects
Which of the following is the correct syntax to declare a class named Person in C#?
APerson class { }
Bclass Person { }
Cclass: Person { }
Dclass Person() { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall C# class declaration syntax

    Classes are declared using the keyword 'class' followed by the class name and curly braces.
  2. Step 2: Check each option

    Only 'class Person { }' matches the correct syntax; others have syntax errors.
  3. Final Answer:

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

    Class declaration syntax = class Name { } [OK]
Quick Trick: Use 'class Name { }' to declare classes [OK]
Common Mistakes:
MISTAKES
  • Using parentheses after class name
  • Writing 'Person class' instead of 'class Person'
  • Using colon instead of braces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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