Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of Console.WriteLine("10" + 20);?
1) 1020
2) 30
3) 10
4) Error
Answer : 1020
Which of the following is a correct way to define a method in C#?
1) public void MyMethod() { }
2) void MyMethod() { }
3) public MyMethod() { }
4) None of the above
Answer : public void MyMethod() { }
What is the output of Console.WriteLine(10.0 / 3);?
1) 3.33
2) 3
3) 3.0
4) 3.5
Answer : 3.33
What is the default access modifier for class members in C#?
1) private
2) protected
3) public
4) internal
Answer : private
Which of the following is used to define a read-only field in C#?
1) readonly
2) const
3) both a and b
4) None of the above
Answer : both a and b
What is the output of Console.WriteLine(5 > 2 ? "Yes" : "No");?
1) Yes
2) No
3) Error
4) None of the above
Answer : Yes
Which of the following is true about a static class in C#?
1) Cannot be instantiated
2) Cannot contain static members
3) Can have constructors
4) None of the above
Answer : Cannot be instantiated
What is the output of Console.WriteLine(5 == "5");?
1) true
2) false
3) Error
4) None of the above
Answer : false
Which of the following is the base class for all classes in C#?
1) System.Object
2) System.Base
3) System.Class
4) None of the above
Answer : System.Object
What is the output of Console.WriteLine(1 != 1);?
1) true
2) false
3) Error
4) None of the above
Answer : false