Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a C# collection that does not allow duplicate elements?
1) List
2) Array
3) HashSet
4) None of the above
Answer : HashSet
What is the output of Console.WriteLine(1 == 1 && 2 == 2);?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is the correct way to declare an array in C#?
1) int[] arr;
2) arr int[];
3) int arr[];
4) None of the above
Answer : int[] arr;
What does the "override" keyword do in C#?
1) Allows a derived class to provide a new implementation of a method.
2) Defines a method as abstract.
3) Prevents method overriding.
4) None of the above
Answer : Allows a derived class to provide a new implementation of a method.
What is the output of Console.WriteLine(5 > 3 || 3 < 2);?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is used to stop the execution of a loop in C#?
1) break
2) continue
3) return
4) None of the above
Answer : break
What is the output of Console.WriteLine(10 - 3 * 2);?
1) 4
2) 8
3) 10
4) None of the above
Answer : 4
Which of the following keywords is used to define an interface in C#?
1) interface
2) class
3) implements
4) None of the above
Answer : interface
What is the output of Console.WriteLine(5 == 5 ? "Yes" : "No");?
1) Yes
2) No
3) Error
4) None of the above
Answer : Yes
Which of the following is the correct way to define a property in C#?
1) public int MyProperty { get; set; }
2) int MyProperty; public get set;
3) MyProperty int public { get; set; }
4) None of the above
Answer : public int MyProperty { get; set; }