Bird
0
0

Which statement correctly describes a read-only property in C#?

easy🧠 Conceptual Q11 of 15
C Sharp (C#) - Properties and Encapsulation

Which statement correctly describes a read-only property in C#?

AIt has only a <code>set</code> accessor and no <code>get</code> accessor.
BIt has only a <code>get</code> accessor and no <code>set</code> accessor.
CIt has both <code>get</code> and <code>set</code> accessors.
DIt has no accessors at all.
Step-by-Step Solution
Solution:
  1. Step 1: Understand property accessors

    A property with only a get accessor allows reading but not writing.
  2. Step 2: Identify read-only property

    Read-only properties have no set accessor, so they cannot be assigned a value.
  3. Final Answer:

    It has only a get accessor and no set accessor. -> Option B
  4. Quick Check:

    Read-only = get only [OK]
Quick Trick: Read-only means only get accessor present [OK]
Common Mistakes:
MISTAKES
  • Confusing read-only with write-only properties
  • Thinking both get and set are needed for read-only
  • Assuming no accessors means read-only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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