Learn C# .Net MCQs

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

What is the output of Console.WriteLine("C# is".Length);?

1) 5

2) 6

3) 7

4) Error

Answer : 5

Which of the following is true about garbage collection in C#?

1) It automatically frees memory.

2) It requires manual intervention.

3) It works only with arrays.

4) None of the above

Answer : It automatically frees memory.

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

1) el

2) ll

3) he

4) Error

Answer : el

Which of the following is used to iterate over elements in a list in C#?

1) foreach

2) for

3) while

4) None of the above

Answer : foreach

Which of the following is used to handle file input/output in C#?

1) System.IO

2) System.File

3) System.FS

4) None of the above

Answer : System.IO

Which of the following is true about exception handling in C#?

1) It uses try-catch blocks.

2) It uses finally blocks.

3) It uses throw statements.

4) All of the above

Answer : All of the above

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

1) 8

2) 6

3) 4

4) None of the above

Answer : 8

Which of the following is used to sort a list in C#?

1) Sort()

2) Order()

3) Arrange()

4) None of the above

Answer : Sort()

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 stop an infinite loop in C#?

1) break

2) continue

3) exit

4) None of the above

Answer : break