Learn C# .Net MCQs

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

What is the output of Console.WriteLine(Math.Sqrt(16));?

1) 4

2) 16

3) Error

4) None of the above

Answer : 4

Which of the following is NOT a built-in data type in C#?

1) float

2) decimal

3) text

4) char

Answer : text

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

1) 52

2) 7

3) Error

4) None of the above

Answer : 52

Which of the following is the correct syntax for a switch statement in C#?

1) switch(variable) { case 1: break; }

2) switch { case 1: }

3) switch(variable): case 1: break;

4) None of the above

Answer : switch(variable) { case 1: break; }

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

1) true

2) false

3) Error

4) None of the above

Answer : true

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

1) const

2) static

3) readonly

4) final

Answer : const

What is the output of Console.WriteLine(5 - 2 * 3);?

1) -1

2) 1

3) 0

4) Error

Answer : -1

Which of the following statements is true about constructors in C#?

1) They can have a return type.

2) They are called when an object is created.

3) They can be private.

4) Both b and c

Answer : Both b and c

What is the output of Console.WriteLine(true || false);?

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following can be used to declare an array in C#?

1) int[] arr;

2) arr int[];

3) int arr;

4) None of the above

Answer : int[] arr;