C# Quiz C# Quiz 1 / 20What is the correct syntax to declare a variable of type int in C#? int varName; var int varName; int: varName; int varName() 2 / 20Which of the following is the correct way to create a new instance of a class named Person? Person p = new Person(); Person p = Person(); Person p = Create Person(); Person p = new Person; 3 / 20What keyword is used to inherit a class in C#? inherits extends implements : 4 / 20Which of the following is a valid access modifier in C#? internal protected internal private All of the above 5 / 20Which of the following types does not support inheritance in C#? sealed abstract static partial 6 / 20What does the override keyword do in C#? Overrides a method in the base class Prevents a method from being overridden Overloads a method in the same class Changes the return type of a method 7 / 20Which of the following statements about interfaces in C# is true? An interface can contain fields. An interface can be instantiated. An interface can inherit multiple interfaces. An interface can contain constructors. 8 / 20How do you handle exceptions in C#? try-catch try-catch-finally throw All of the above 9 / 20What is the purpose of the using statement in C#? It is used to include namespaces It defines the scope at the end of which an object will be disposed. It handles exceptions. It is used for memory management 10 / 20Which collection is ordered in C#? List HashSet Dictionary Queue 11 / 20Which keyword is used to define a property in a class? prop property getset get; set; 12 / 20What is the correct way to declare a nullable integer in C#? int? i = null; nullable int i = null; int i? = null; int i = null; 13 / 20What is a delegate in C#? A variable that can hold a reference to a method A type-safe function pointer A way to pass methods as arguments All of the above 14 / 20Which of the following methods is used to sort an array in C#? Array.Sort() Array.Order() Array.SortArray() Array.OrderArray() 15 / 20What is the base class for all classes in .NET? Object System Base Class 16 / 20How do you declare a constant field in a class? const int x = 10; readonly int x = 10; static int x = 10; final int x = 10; 17 / 20What does the is keyword do in C#? Compares two objects for reference equality Checks if an object is of a specific type Compares two objects for value equality Casts an object to a specified type 18 / 20Which of the following methods is used to add an element to a List<T> in C#? AddElement() Insert() Append() Add() 19 / 20What is the purpose of the yield keyword in C#? To return a value from a method To indicate that a method is asynchronous To return an iterator from a method To indicate that a method is obsolete 20 / 20What does the readonly keyword do when applied to a field? Prevents the field from being modified after declaration Prevents the field from being accessed outside the class Allows the field to be modified only within the constructor Allows the field to be modified only within the class Your score isThe average score is 40% 0% Restart quiz