Learn C# .Net MCQs

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

Which of the following is a value type in C#?

1) string

2) object

3) int

4) List<T>

Answer : int

What is the purpose of the "base" keyword in C#?

1) To access base class members

2) To create a new instance

3) To define a constant

4) None of the above

Answer : To access base class members

What is the output of Console.WriteLine(4 + 3 / 2);?

1) 6

2) 6.5

3) 7

4) Error

Answer : 6

Which of the following is used to catch multiple exceptions in C#?

1) catch

2) try-catch

3) try-catch-finally

4) catch-finally

Answer : try-catch

What is the output of Console.WriteLine(3 * 2 / 3);?

1) 2

2) 3

3) 1

4) Error

Answer : 2

Which of the following keywords is used to declare a struct in C#?

1) struct

2) class

3) record

4) None of the above

Answer : struct

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

1) 3

2) 4

3) 2

4) Error

Answer : 3

Which of the following is NOT a valid C# data type?

1) integer

2) float

3) string

4) bool

Answer : integer

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

1) 55

2) 10

3) 5

4) Error

Answer : 55

Which of the following is a collection type in C#?

1) List<T>

2) Dictionary<TKey, TValue>

3) Both a and b

4) None of the above

Answer : Both a and b