C# - Structures Questions and Answers
Practice ModeShowing 10 of 39 questions
Q21
Can a structure have a parameterless constructor
Answer: Option B
Explanation: Structures cannot define a parameterless constructor explicitly.
Q22
Which access modifier is allowed for structure members
Answer: Option B
Explanation: Structure members can have access modifiers like private and public.
Q23
Which statement about structures and classes is correct
Answer: Option C
Explanation: Structures are value types while classes are reference types.
Q24
What happens when a structure variable is assigned to another
Answer: Option C
Explanation: Assigning a structure copies the entire value.
Q25
Which interface can a structure implement
Answer: Option B
Explanation: Structures can implement one or more interfaces.
Q26
Which keyword is used to prevent modification of structure fields
Answer: Option C
Explanation: The readonly keyword prevents modification after initialization.
Q27
Which of the following is true about structure size
Answer: Option C
Explanation: Structures usually consume less memory than class objects.
Q28
Which scenario is best suited for using a structure
Answer: Option C
Explanation: Structures are ideal for small and simple data objects.
Q29
Which keyword allows a structure to be passed by reference
Answer: Option D
Explanation: Structures can be passed by reference using ref, out, or in.
Q30
Which of the following statements is invalid for a structure
Answer: Option C
Explanation: Structures cannot inherit from other structures.