Learn C# .Net MCQs

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

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

1) 3

2) 2

3) Error

4) None of the above

Answer : 3

Which of the following is used to define an event in C#?

1) event EventHandler myEvent;

2) delegate EventHandler myEvent;

3) public EventHandler myEvent;

4) None of the above

Answer : event EventHandler myEvent;

What is the output of Console.WriteLine(Math.PI);?

1) 3.14

2) 3.14159

3) Error

4) None of the above

Answer : 3.14159

Which of the following statements is true about the "string" type in C#?

1) Strings are mutable

2) Strings are reference types

3) Strings cannot be null

4) None of the above

Answer : Strings are reference types

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

1) 11

2) 14

3) 10

4) Error

Answer : 11

Which of the following is used to implement inheritance in C#?

1) class Derived : Base

2) class Derived inherits Base

3) class Derived extends Base

4) None of the above

Answer : class Derived : Base

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

1) Creates a new instance of an object

2) Declares a variable

3) Defines a method

4) None of the above

Answer : Creates a new instance of an object

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

1) ArrayList

2) Dictionary

3) List

4) Tuple

Answer : Tuple

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

1) HELLO

2) hello

3) Error

4) None of the above

Answer : HELLO

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

1) int?

2) double?

3) Both a and b

4) None of the above

Answer : Both a and b