Learn C# .Net MCQs

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

What is the output of Console.WriteLine(4 / 3);?

1) 1

2) 1.333

3) Error

4) None of the above

Answer : 1

Which of the following is true about the "using" statement in C#?

1) It must be used with namespaces.

2) It is used to manage resources.

3) It can only be used for IDisposable objects.

4) Both b and c

Answer : Both b and c

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

1) 5 apples

2) 5apples

3) Error

4) None of the above

Answer : 5 apples

Which of the following is a method of the string class in C#?

1) ToLower()

2) ToUpper()

3) Substring()

4) All of the above

Answer : All of the above

Which of the following keywords is used to define a class in C#?

1) class

2) struct

3) interface

4) module

Answer : class

What is the output of Console.WriteLine(10 > 5 ? "Yes" : "No");?

1) Yes

2) No

3) Error

4) None of the above

Answer : Yes

Which of the following is a collection type in C#?

1) List<T>

2) Dictionary<K,V>

3) HashSet<T>

4) All of the above

Answer : All of the above

What is the purpose of the "finally" block in C#?

1) To handle exceptions

2) To execute code after try-catch

3) To declare a method

4) None of the above

Answer : To execute code after try-catch

Which of the following is a valid way to declare an array in C#?

1) int[] numbers;

2) int numbers[];

3) numbers int[];

4) None of the above

Answer : int[] numbers;

What is the output of Console.WriteLine(10.0 / 3);?

1) 3.33

2) 3

3) 3.0

4) Error

Answer : 3.33333333333333