Learn C# .Net MCQs

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

Which of the following is true about the "readonly" keyword in C#?

1) It allows modification only in the constructor.

2) It allows modification anywhere in the class.

3) It cannot be modified.

4) None of the above

Answer : It allows modification only in the constructor.

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

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following is used to define an enum in C#?

1) enum

2) enumType

3) Enum

4) None of the above

Answer : enum

Which of the following is true about a finalizer in C#?

1) It is called automatically when the object is destroyed.

2) It is called manually.

3) It has parameters.

4) None of the above

Answer : It is called automatically when the object is destroyed.

Which of the following is the correct way to declare a nullable value type in C#?

1) int? num;

2) nullable int num;

3) int num = null;

4) None of the above

Answer : int? num;

What is the output of Console.WriteLine("Hello".Substring(0, 3));?

1) Hel

2) lo

3) Error

4) None of the above

Answer : Hel

Which of the following is used to define an extension method in C#?

1) this

2) new

3) extension

4) None of the above

Answer : this

Which of the following is used to check if an object is null in C#?

1) == null

2) isNull()

3) is null

4) None of the above

Answer : == null

What is the output of Console.WriteLine(Math.Round(5.5));?

1) 6

2) 5

3) 5.5

4) Error

Answer : 6

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

1) They are type-safe.

2) They are not type-safe.

3) They are only used for events.

4) None of the above

Answer : They are type-safe.