Learn C# .Net MCQs
Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is the correct way to declare a nullable type in C#?
1) int?
2) int!
3) nullable<int>
4) None of the above
Answer : int?
What is the output of Console.WriteLine("123".Length);?
1) 3
2) 2
3) Error
4) None of the above
Answer : 3
Which of the following is NOT an access modifier in C#?
1) private
2) protected
3) internal
4) public-private
Answer : public-private
What is the output of Console.WriteLine(5 / 2);?
1) 2
2) 2.5
3) Error
4) None of the above
Answer : 2
Which of the following methods can be used to convert a string to an integer?
1) Convert.ToInt32()
2) int.Parse()
3) Both a and b
4) None of the above
Answer : Both a and b
What is the output of Console.WriteLine(10 % 3);?
1) 1
2) 2
3) 3
4) Error
Answer : 1
Which of the following is true about the `async` and `await` keywords in C#?
1) They enable asynchronous programming
2) They can be used together
3) Both a and b
4) None of the above
Answer : Both a and b
What is the output of Console.WriteLine(5 == 5 && 3 != 3);?
1) true
2) false
3) Error
4) None of the above
Answer : false
Which of the following is a correct way to implement a constructor in C#?
1) public ClassName() { }
2) void ClassName() { }
3) ClassName() { }
4) None of the above
Answer : public ClassName() { }
What is the output of Console.WriteLine("CSharp".Substring(0, 2));?
1) CS
2) C#
3) Error
4) None of the above
Answer : CS