Learn C# .Net MCQs

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

What keyword is used to implement an interface in C#?

1) implements

2) inherits

3) interface

4) None of the above

Answer : None of the above

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

1) They can have get and set accessors

2) They can be private

3) Both a and b

4) None of the above

Answer : Both a and b

What is the default value of a string in C#?

1) null

2) ""

3) undefined

4) 0

Answer : null

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

1) 55

2) 10

3) Error

4) None of the above

Answer : 55

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

1) namespace

2) namespace MyNamespace {}

3) using MyNamespace;

4) None of the above

Answer : namespace MyNamespace {}

What is the output of Console.WriteLine(1 == 1 ? "Yes" : "No");?

1) Yes

2) No

3) Error

4) None of the above

Answer : Yes

Which of the following is a method of the string class in C#?

1) Contains()

2) Add()

3) Remove()

4) Both a and c

Answer : Both a and c

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

1) 1020

2) 30

3) Error

4) None of the above

Answer : 1020

Which of the following can be a nullable type in C#?

1) int?

2) double?

3) DateTime?

4) All of the above

Answer : All of the above

What is the purpose of the "lock" statement in C#?

1) To restrict access to a block of code

2) To handle exceptions

3) To create a new thread

4) None of the above

Answer : To restrict access to a block of code