Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a valid C# comment?
1) // This is a comment
2) # This is a comment
3) /* This is a comment */
4) Both a and c
Answer : Both a and c
What is the output of Console.WriteLine(0 == 0 ? "Yes" : "No");?
1) Yes
2) No
3) Error
4) None of the above
Answer : Yes
Which of the following is NOT a built-in value type in C#?
1) bool
2) int
3) string
4) char
Answer : string
What does the "params" keyword do in C#?
1) Allows variable number of arguments
2) Defines an array
3) Defines a method
4) None of the above
Answer : Allows variable number of arguments
Which of the following is a valid way to implement multiple interfaces in C#?
1) class MyClass : IFirst, ISecond
2) class MyClass implements IFirst, ISecond
3) class MyClass extends IFirst, ISecond
4) None of the above
Answer : class MyClass : IFirst, ISecond
What is the output of Console.WriteLine("10" + 5);?
1) 105
2) 15
3) Error
4) None of the above
Answer : 105
Which of the following is used to define a destructor in C#?
1) ~ClassName() {}
2) class ClassName() {}
3) ClassName() {}
4) None of the above
Answer : ~ClassName() {}
What is the output of Console.WriteLine(5 + " apples");?
1) 5 apples
2) Error
3) 5apples
4) None of the above
Answer : 5 apples
Which of the following is a way to handle exceptions in C#?
1) try-catch
2) try-finally
3) catch-finally
4) Both a and b
Answer : Both a and b
What is the output of Console.WriteLine(Math.Max(5, 10));?
1) 5
2) 10
3) Error
4) None of the above
Answer : 10