C# - Structures Questions and Answers
Practice ModeShowing 10 of 39 questions
Q31
What is boxing in relation to structures
Answer: Option B
Explanation: Boxing converts a value type into an object type.
Q32
What is unboxing in C#
Answer: Option A
Explanation: Unboxing extracts the value type from an object.
Q33
Which of the following can a structure not contain
Answer: Option C
Explanation: Structures cannot contain destructors.
Q34
What is the base type of all structures in C#
Answer: Option A
Explanation: All structures implicitly inherit from System.ValueType.
Q35
Which statement about mutable structures is correct
Answer: Option C
Explanation: Structures are mutable unless fields are marked readonly.
Q36
Which keyword makes a structure immutable
Answer: Option C
Explanation: Using readonly fields helps make structures immutable.
Q37
Which of the following is a valid use of a structure
Answer: Option C
Explanation: Structures are suitable for small data-centric types like points.
Q38
What happens if a structure is not initialized explicitly
Answer: Option C
Explanation: Structure fields are automatically initialized to default values.
Q39
Which statement about performance of structures is true
Answer: Option B
Explanation: Structures reduce heap allocation and garbage collection overhead.