Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a collection type that allows duplicate elements in C#?
1) HashSet
2) List
3) Dictionary
4) None of the above
Answer : List
What is the output of Console.WriteLine("a" == "A");?
1) true
2) false
3) Error
4) None of the above
Answer : false
Which of the following is used to implement an interface in C#?
1) class MyClass : IMyInterface {}
2) class MyClass implements IMyInterface {}
3) class MyClass extends IMyInterface {}
4) None of the above
Answer : class MyClass : IMyInterface {}
What is the output of Console.WriteLine(1 + 2 * 3);?
1) 7
2) 8
3) 6
4) None of the above
Answer : 7
What is the purpose of the "lock" keyword in C#?
1) To prevent multiple threads from accessing a block of code.
2) To define a method that can be executed in parallel.
3) To create a mutex.
4) None of the above
Answer : To prevent multiple threads from accessing a block of code.
Which of the following is the correct way to comment a single line in C#?
1) // comment
2) # comment
3) /* comment */
4) None of the above
Answer : // comment
What is the output of Console.WriteLine(4 + 5 - 3);?
1) 6
2) 5
3) Error
4) None of the above
Answer : 6
Which keyword is used to handle exceptions in C#?
1) try
2) catch
3) finally
4) None of the above
Answer : catch
What is the output of Console.WriteLine("Hello".StartsWith("H"));?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is the correct syntax to declare an array in C#?
1) int[] arr;
2) int arr[];
3) arr int[];
4) None of the above
Answer : int[] arr;