Learn C# .Net MCQs

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

What is the output of Console.WriteLine("abc".Replace("a", "z"));?

1) zbc

2) abc

3) Error

4) None of the above

Answer : zbc

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

1) const

2) static

3) readonly

4) None of the above

Answer : const

What is the output of Console.WriteLine(20 == 20);?

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following is true about a virtual method in C#?

1) It can be overridden in a derived class.

2) It must be overridden.

3) It cannot have a body.

4) None of the above

Answer : It can be overridden in a derived class.

What is the output of Console.WriteLine(15 ^ 7);?

1) 0

2) 8

3) 10

4) None of the above

Answer : 8

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

1) Abstract classes

2) Interfaces

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

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

1) 4

2) 5

3) 6

4) Error

Answer : 5

Which of the following is true about a destructor in C#?

1) It is called automatically when an object is destroyed.

2) It can be called manually.

3) It can have parameters.

4) None of the above

Answer : It is called automatically when an object is destroyed.

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

1) 1

2) 2

3) 3

4) None of the above

Answer : 2

Which of the following is true about a static method in C#?

1) It belongs to the class.

2) It can be called using an object.

3) Both 1 and 2

4) None of the above

Answer : It belongs to the class.