Learn C# .Net MCQs

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

What is the output of Console.WriteLine(Math.Max(10, 20));?

1) 10

2) 20

3) 0

4) None of the above

Answer : 20

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

1) It initializes objects.

2) It must be public.

3) It returns a value.

4) None of the above

Answer : It initializes objects.

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

1) Inheritance

2) Abstract classes

3) Interfaces

4) None of the above

Answer : Interfaces

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 the correct way to declare a static method in C#?

1) public static void MyMethod()

2) static public void MyMethod()

3) void static MyMethod()

4) None of the above

Answer : public static void MyMethod()

What is the output of Console.WriteLine("C# is fun!".Contains("fun"));?

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following is true about an abstract method in C#?

1) It has no implementation.

2) It can be called directly.

3) It must be static.

4) None of the above

Answer : It has no implementation.

Which of the following is the correct way to create a string in C#?

1) string str = "Hello";

2) String str = new String("Hello");

3) char[] str = "Hello";

4) None of the above

Answer : string str = "Hello";

Which of the following is used to find the length of an array in C#?

1) Length

2) Size

3) Count

4) None of the above

Answer : Length

What is the output of Console.WriteLine("Hello"[0]);?

1) H

2) e

3) l

4) Error

Answer : H