C# - Properties MCQ Questions and Answers

Practice Mode
Showing 10 of 30 questions
Q21
What is an abstract property?
  • A A property that is automatically implemented
  • B A property declared without implementation in abstract class
  • C A static property
  • D A property with private setter
Answer: Option B
Explanation: Abstract properties are declared in abstract classes and implemented in derived classes.
Q22
Which property validation occurs in the set accessor?
  • A Input validation
  • B Output formatting
  • C Memory allocation
  • D Exception handling
Answer: Option A
Explanation: Property setters commonly validate input data before assignment.
Q23
What is the purpose of interface properties?
  • A To provide default implementation
  • B To define property contracts for implementation
  • C To create auto-implemented properties
  • D To make properties static
Answer: Option B
Explanation: Interface properties define property contracts that implementing classes must fulfill.
Q24
Which property type is initialized only once?
  • A Read-only property
  • B Write-only property
  • C Init-only property
  • D Static property
Answer: Option C
Explanation: Init-only properties can be set only during object initialization.
Q25
What happens if a property has only a private set accessor?
  • A The property becomes write-only
  • B The property can be set only within the class
  • C The property becomes read-only externally
  • D The property cannot be accessed at all
Answer: Option C
Explanation: Private setters restrict external modification while allowing internal access.
Q26
Which property feature enables data binding in WPF?
  • A Auto-implementation
  • B Change notifications
  • C Static modifier
  • D Private setters
Answer: Option B
Explanation: Properties support change notifications for data binding scenarios.
Q27
What is a virtual property in C#?
  • A A property that must be implemented
  • B A property that can be overridden in derived classes
  • C A static property
  • D An abstract property
Answer: Option B
Explanation: Virtual properties can be overridden in derived classes.
Q28
Which property type cannot be overridden in derived classes?
  • A Virtual property
  • B Abstract property
  • C Sealed property
  • D Override property
Answer: Option C
Explanation: Sealed properties prevent further overriding in inheritance hierarchy.
Q29
What is the purpose of expression-bodied properties?
  • A To make properties faster
  • B To provide concise syntax for simple properties
  • C To make properties thread-safe
  • D To enable property inheritance
Answer: Option B
Explanation: Expression-bodied properties provide concise syntax for simple properties.
Q30
Which property characteristic enables LINQ queries?
  • A Property setters
  • B Property getters
  • C Property accessibility
  • D Property values and types
Answer: Option D
Explanation: Properties provide the data structure that LINQ queries operate on.
Questions and Answers for Competitive Exams Various Entrance Test