Learn C# .Net MCQs

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

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

1) void MyMethod() {}

2) MyMethod() {}

3) define MyMethod() {}

4) None of the above

Answer : void MyMethod() {}

What is the output of Console.WriteLine(10 < 5 ? "True" : "False");?

1) True

2) False

3) Error

4) None of the above

Answer : False

Which of the following data types is not a reference 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 class-level members.

2) To define instance members.

3) To define a constant variable.

4) None of the above

Answer : To define class-level members.

Which of the following is a valid way to declare an array in C#?

1) int[] arr = new int[5];

2) int arr[] = new int[5];

3) int arr = new int[5];

4) None of the above

Answer : int[] arr = new int[5];

What is the output of Console.WriteLine("Hello World".Substring(0, 5));?

1) Hello

2) Hello World

3) Error

4) None of the above

Answer : Hello

Which of the following is true about the "async" and "await" keywords in C#?

1) They are used for asynchronous programming.

2) They cannot be used together.

3) They block the main thread.

4) None of the above

Answer : They are used for asynchronous programming.

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

1) 17

2) 15

3) 12

4) None of the above

Answer : 17

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

1) int?

2) int!

3) int~

4) None of the above

Answer : int?

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

1) true

2) false

3) Error

4) None of the above

Answer : true