Section 1: Multiple Choice
1. What is an enum in C#?
enum in C#?A collection of methods
A data type that stores multiple values in a list
A way to define a set of named integer constants
A class that can have multiple instances
2. What is the default access modifier in C#?
publicprivateprotectedinternal
3. What does sealed do in a class declaration?
sealed do in a class declaration?Prevents it from being instantiated
Prevents it from being inherited
Prevents modification of its properties
Turns it into a static class
4. Which of these is a correct way to define a property in C#?
public string Name { get; set; }public string Name() { get; set; }public string Name = "default";private string Name { get };
5. How do you declare an interface in C#?
class IExample {}interface IExample {}public static IExample {}abstract IExample {}
6. What will this code output?
10
20
Null
Compilation error
7. What is the default value of an uninitialised bool variable in C#?
bool variable in C#?nulltruefalse0
8. What does readonly do in C#?
Makes a variable accessible only inside a class
Allows modification only in the constructor
Prevents modification entirely
Applies to only static variables
9. What happens if you do not explicitly set a value for an enum member?
enum member?It defaults to
nullIt takes the value
0and increments for subsequent numbersIt must be set explicitly
It causes a compilation error
10. How do you call a method in another class?
ClassName.MethodName();MethodName.ClassName();this.MethodName();new MethodName();
Last updated