Learn C# .Net MCQs

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

Which of the following is used to implement multiple inheritance in C#?

1) Interfaces

2) Abstract classes

3) Classes

4) None of the above

Answer : Interfaces

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

1) ell

2) hel

3) llo

4) None of the above

Answer : ell

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

1) They are used to access fields.

2) They must have both get and set accessors.

3) They cannot be static.

4) None of the above

Answer : They are used to access fields.

What is the output of Console.WriteLine(Math.Pow(2, 3));?

1) 6

2) 8

3) 9

4) None of the above

Answer : 8

Which of the following is the correct way to catch an exception in C#?

1) try-catch

2) try-except

3) catch-finally

4) None of the above

Answer : try-catch

Which of the following is used to achieve encapsulation in C#?

1) Properties

2) Methods

3) Fields

4) None of the above

Answer : Properties

What is the output of Console.WriteLine("Hello".ToLower());?

1) HELLO

2) hello

3) Hello

4) None of the above

Answer : hello

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

1) It cannot be inherited.

2) It cannot be instantiated.

3) It must be abstract.

4) None of the above

Answer : It cannot be inherited.

What is the output of Console.WriteLine(15 | 7);?

1) 7

2) 15

3) 31

4) None of the above

Answer : 15

Which of the following is used to implement polymorphism in C#?

1) Interfaces

2) Inheritance

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2