Learn C# .Net MCQs

Prepare C# .Net MCQs (Multiple choice Questions) for exam and job interviews.

What is the output of Console.WriteLine(5 > 2 && 3 < 1);?

1) true

2) false

3) Error

4) None of the above

Answer : false

Which of the following is the correct syntax for a try-catch block in C#?

1) try {} catch {}

2) try {} catch (Exception e) {}

3) try (Exception e) {}

4) None of the above

Answer : try {} catch (Exception e) {}

What is the output of Console.WriteLine(10 / 2 * 3);?

1) 15

2) 30

3) 5

4) None of the above

Answer : 15

Which of the following is not an operator in C#?

1) ==

2) !=

3) =>

4) ===

Answer : ===

What is the purpose of the "volatile" keyword in C#?

1) To prevent the compiler from optimizing code.

2) To mark a variable as a global variable.

3) To define a constant variable.

4) None of the above

Answer : To prevent the compiler from optimizing code.

What is the output of Console.WriteLine("2" + "3");?

1) 23

2) 5

3) Error

4) None of the above

Answer : 23

Which of the following keywords is used to declare a constant in C#?

1) const

2) static

3) readonly

4) None of the above

Answer : const

What is the output of Console.WriteLine(3 + 4 * 2);?

1) 11

2) 14

3) 10

4) None of the above

Answer : 11

Which of the following is used to throw an exception in C#?

1) throw new Exception();

2) raise Exception();

3) throw Exception();

4) None of the above

Answer : throw new Exception();

What is the output of Console.WriteLine("abc".Length);?

1) 3

2) 2

3) Error

4) None of the above

Answer : 3