Learn C# .Net MCQs

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

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

1) It prevents inheritance.

2) It allows multiple inheritance.

3) It only applies to methods.

4) None of the above

Answer : It prevents inheritance.

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

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following is used to remove an element from a list in C#?

1) Remove()

2) Delete()

3) Clear()

4) None of the above

Answer : Remove()

What is the output of Console.WriteLine(10 % 3);?

1) 1

2) 2

3) 0

4) None of the above

Answer : 1

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

1) String.Format()

2) FormatString()

3) Format()

4) None of the above

Answer : String.Format()

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

1) csharp

2) CSHARP

3) CSharp

4) None of the above

Answer : csharp

Which of the following is used to handle null values in C#?

1) ??

2) != null

3) isNull()

4) None of the above

Answer : ??

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

1) 5

2) 25

3) 0

4) None of the above

Answer : 5

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

1) Reverse()

2) String.Reverse()

3) Array.Reverse()

4) None of the above

Answer : Array.Reverse()

Which of the following is used to check if a list contains a specific element in C#?

1) Contains()

2) Has()

3) Find()

4) None of the above

Answer : Contains()