Learn C# .Net MCQs

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

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

1) int

2) var

3) string

4) All of the above

Answer : All of the above

Which of the following is used to concatenate strings in C#?

1) +

2) concat()

3) join()

4) None of the above

Answer : +

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

1) hello

2) HELLO

3) Error

4) None of the above

Answer : hello

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

1) const

2) static

3) readonly

4) None of the above

Answer : const

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

1) true

2) false

3) Error

4) None of the above

Answer : true

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

1) readonly

2) const

3) static

4) None of the above

Answer : readonly

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

1) throw

2) raise

3) generate

4) None of the above

Answer : throw

What is the output of Console.WriteLine(5 < 10);?

1) true

2) false

3) Error

4) None of the above

Answer : true

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

1) It hides the implementation details.

2) It exposes the data.

3) It only applies to public members.

4) None of the above

Answer : It hides the implementation details.

What is the output of Console.WriteLine("Hello".Replace("l", "p"));?

1) Heppo

2) Hplpo

3) Helo

4) Error

Answer : Heppo