C# - Properties MCQ Questions and Answers
Practice ModeShowing 10 of 30 questions
Q11
What is the main purpose of properties in C#?
Answer: Option B
Explanation: Properties provide controlled access to private fields through get and set accessors.
Q12
Which of the following is an auto-implemented property?
Answer: Option A
Explanation: Auto-implemented properties have simplified syntax without explicit backing fields.
Q13
What is a read-only property in C#?
Answer: Option B
Explanation: Read-only properties have only get accessor and cannot be modified externally.
Q14
Which access modifier is commonly used for property setters to make properties read-only?
Answer: Option B
Explanation: Private setters allow internal modification while preventing external changes.
Q15
What is the purpose of the "value" keyword in property setters?
Answer: Option B
Explanation: The value keyword represents the data being assigned to the property.
Q16
Which property type allows both get and set operations?
Answer: Option C
Explanation: Read-write properties have both get and set accessors.
Q17
What is a static property in C#?
Answer: Option B
Explanation: Static properties belong to the class rather than specific instances.
Q18
Which property has only a set accessor?
Answer: Option B
Explanation: Write-only properties are rare but useful for specific scenarios like passwords.
Q19
What is the default accessibility of get and set accessors in properties?
Answer: Option B
Explanation: Accessors inherit the property accessibility unless specified otherwise.
Q20
Which keyword is used to create calculated properties?
Answer: Option C
Explanation: Calculated properties compute values rather than storing them directly.