Learn C# .Net MCQs

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

What does the "protected" access modifier do in C#?

1) Allows access only within the same class.

2) Allows access to derived classes.

3) Allows access to all classes.

4) None of the above

Answer : Allows access to derived classes.

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

1) 14

2) 16

3) Error

4) None of the above

Answer : 14

Which of the following is used to convert a string to uppercase in C#?

1) ToUpper()

2) Uppercase()

3) None of the above

4) Convert.ToUpper()

Answer : ToUpper()

Which keyword is used to inherit a class in C#?

1) base

2) inherit

3) extends

4) None of the above

Answer : None of the above

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

1) 4

2) Error

3) 22

4) None of the above

Answer : 22

Which of the following is an abstract class in C#?

1) A class that cannot be instantiated.

2) A class with all methods defined.

3) A class with no methods.

4) None of the above

Answer : A class that cannot be instantiated.

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

1) 55

2) 10

3) Error

4) None of the above

Answer : 55

Which of the following is a method to parse a string to a double in C#?

1) Convert.ToDouble()

2) Double.Parse()

3) Both of the above

4) None of the above

Answer : Both of the above

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 not a part of the C# Exception handling mechanism?

1) try

2) catch

3) finally

4) pass

Answer : pass