Bird
Raised Fist0

Which of the following is the correct way to declare a static field in a C# class?

easy📝 Syntax Q12 of Q15
C Sharp (C#) - Classes and Objects
Which of the following is the correct way to declare a static field in a C# class?
Apublic static int count;
Bpublic int static count;
Cpublic int count;
Dint static public count;
Step-by-Step Solution
Solution:
  1. Step 1: Recall C# static field syntax

    The correct order is access modifier, then 'static', then type and name.
  2. Step 2: Check each option

    public static int count; matches the correct syntax: 'public static int count;'. Others have wrong order or missing keywords.
  3. Final Answer:

    public static int count; -> Option A
  4. Quick Check:

    Access modifier + static + type + name [OK]
Quick Trick: Use 'public static' before type for static fields [OK]
Common Mistakes:
MISTAKES
  • Placing 'static' after the type
  • Omitting 'static' keyword
  • Incorrect order of keywords

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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