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) int

3) object

4) None of the above

Answer : int

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

1) To define a variable that can be used across all instances.

2) To define a method that can be accessed without an instance.

3) Both of the above

4) None of the above

Answer : Both of the above

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

1) 3

2) 1

3) 10

4) None of the above

Answer : 1

Which of the following is used to define a delegate in C#?

1) delegate void MyDelegate();

2) MyDelegate delegate;

3) void MyDelegate();

4) None of the above

Answer : delegate void MyDelegate();

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

1) 7

2) 10

3) Error

4) None of the above

Answer : 7

Which operator is used to check for equality in C#?

1) =

2) ==

3) ===

4) None of the above

Answer : ==

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

1) ab

2) bc

3) a

4) None of the above

Answer : bc

What does the "sealed" keyword do in C#?

1) Prevents a class from being inherited.

2) Allows a class to be inherited.

3) Makes a class abstract.

4) None of the above

Answer : Prevents a class from being inherited.

Which of the following is used to raise an exception in C#?

1) throw

2) raise

3) catch

4) None of the above

Answer : throw

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

1) 55

2) 10

3) 5

4) None of the above

Answer : 55