Learn C# .Net MCQs

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

Which of the following is true about static methods in C#?

1) They can access instance variables.

2) They cannot be called without an instance.

3) They can only be called from a static context.

4) None of the above

Answer : They can only be called from a static context.

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

1) 4

2) 6

3) 8

4) Error

Answer : 4

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

1) delegate int MyDelegate();

2) delegate MyDelegate();

3) int MyDelegate();

4) None of the above

Answer : delegate int MyDelegate();

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

1) true

2) false

3) Error

4) None of the above

Answer : false

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

1) int[] arr = {1, 2, 3};

2) int arr[] = {1, 2, 3};

3) int arr[3] = {1, 2, 3};

4) None of the above

Answer : int[] arr = {1, 2, 3};

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

1) 55

2) 10

3) 5

4) Error

Answer : 55

Which of the following is true about interfaces in C#?

1) Interfaces cannot contain properties.

2) Interfaces can contain methods without implementations.

3) Classes can inherit from multiple interfaces.

4) Both b and c

Answer : Both b and c

What is the output of Console.WriteLine(5 == 5 || 4 == 5);?

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following is a way to define an anonymous method in C#?

1) delegate { }

2) action { }

3) void { }

4) None of the above

Answer : delegate { }

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

1) 33

2) 6

3) Error

4) None of the above

Answer : 33