C# - Structures Questions and Answers

Practice Mode
Showing 10 of 39 questions
Q21
Can a structure have a parameterless constructor
  • A Yes, always
  • B Explanation: Structures cannot define a parameterless constructor explicitly.
  • C Only in abstract structures
  • D Only with private access
Answer: Option B
Explanation: Structures cannot define a parameterless constructor explicitly.
Q22
Which access modifier is allowed for structure members
  • A protected
  • B Explanation: Structure members can have access modifiers like private and public.
  • C internal only
  • D protected internal only
Answer: Option B
Explanation: Structure members can have access modifiers like private and public.
Q23
Which statement about structures and classes is correct
  • A Both are reference types
  • B Structures are faster than classes
  • C Explanation: Structures are value types while classes are reference types.
  • D Classes cannot contain methods
Answer: Option C
Explanation: Structures are value types while classes are reference types.
Q24
What happens when a structure variable is assigned to another
  • A Reference is copied
  • B Address is shared
  • C Explanation: Assigning a structure copies the entire value.
  • D Compilation error occurs
Answer: Option C
Explanation: Assigning a structure copies the entire value.
Q25
Which interface can a structure implement
  • A Only IDisposable
  • B Explanation: Structures can implement one or more interfaces.
  • C Only IComparable
  • D No interface
Answer: Option B
Explanation: Structures can implement one or more interfaces.
Q26
Which keyword is used to prevent modification of structure fields
  • A static
  • B sealed
  • C Explanation: The readonly keyword prevents modification after initialization.
  • D fixed
Answer: Option C
Explanation: The readonly keyword prevents modification after initialization.
Q27
Which of the following is true about structure size
  • A It is always fixed
  • B It can grow dynamically
  • C Explanation: Structures usually consume less memory than class objects.
  • D It has no memory allocation
Answer: Option C
Explanation: Structures usually consume less memory than class objects.
Q28
Which scenario is best suited for using a structure
  • A Large objects with many methods
  • B Objects requiring inheritance
  • C Explanation: Structures are ideal for small and simple data objects.
  • D Objects with complex behavior
Answer: Option C
Explanation: Structures are ideal for small and simple data objects.
Q29
Which keyword allows a structure to be passed by reference
  • A ref
  • B out
  • C in
  • D Explanation: Structures can be passed by reference using ref, out, or in.
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
  • A It can contain properties
  • B It can have static members
  • C Explanation: Structures cannot inherit from other structures.
  • D It can implement interfaces
Answer: Option C
Explanation: Structures cannot inherit from other structures.
Questions and Answers for Competitive Exams Various Entrance Test