In this quiz, we will test your understanding of C# structures and their differences from classes. Structures, while sharing some similarities with classes, have unique characteristics such as being value types, which are copied by value and stored on the stack. You will be challenged on the concepts of value vs. reference types, immutability, copying behavior, and when to choose structures over classes. This quiz will also explore the key features of structures, such as their inability to support inheritance, their ability to implement interfaces, and other related concepts.
1.
What keyword is used to declare a structure in C#?
2.
Which of the following statements is true about C# structures?
3.
How do structures differ from classes in terms of memory handling?
4.
What happens when a structure instance is copied or passed as a method argument?
5.
Which of the following statements about C# structures is FALSE?
6.
How are class instances passed when used as method arguments?
7.
Which of the following features is unique to classes and NOT supported by structures in C#?
8.
What does the 'readonly' keyword do when applied to a structure?
9.
Which keyword is required when declaring a C# structure as immutable?
10.
Which of the following cannot be declared within a C# structure?
11.
What is the key difference in behavior between classes and structures in terms of copying instances?
12.
Which of the following keywords is used to declare a structure in C#?
13.
What will happen if you modify a copy of a structure instance?
14.
Which of the following is NOT a characteristic of a C# structure?
15.
Which of the following operations can be performed with both C# classes and structures?
16.
When should you prefer using a structure over a class in C#?