Bird
0
0

In C#, what is the primary characteristic of a property that only has a get accessor?

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

In C#, what is the primary characteristic of a property that only has a get accessor?

AIt can be both read and written from outside the class.
BIt can be written to but not read from outside the class.
CIt can neither be read nor written from outside the class.
DIt can be read but not modified from outside the class.
Step-by-Step Solution
Solution:
  1. Step 1: Understand property accessors

    A property with only a get accessor allows reading the value but no external modification.
  2. Step 2: Analyze options

    It can be read but not modified from outside the class. correctly states the behavior of a read-only property.
  3. Final Answer:

    It can be read but not modified from outside the class. -> Option D
  4. Quick Check:

    Read-only means get only, no set [OK]
Quick Trick: Get-only means read-only property [OK]
Common Mistakes:
MISTAKES
  • Confusing read-only with write-only properties
  • Assuming get-only properties can be set externally

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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