iGET

C# Programming - MCQ Practice Questions

C# (.NET) MCQs — OOP, collections, LINQ & exception handling.

290 questions | 100% Free

Q.1Easy

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

Q.2Easy

Which keyword is used to create a class in C#?

Q.3Medium

What will be the output of the following code snippet? int x = 5; int y = ++x; Console.WriteLine(x + " " + y);

Q.4Medium

Which of the following data types in C# is a value type?

Q.5Medium

What is the correct way to declare a constant variable in C#?

Q.6Easy

Which namespace is required to use Console.WriteLine() in C#?

Q.7Medium

What is the difference between '==' and 'Equals()' when comparing strings in C#?

Q.8Medium

Which of the following will correctly convert a string to an integer in C#?

Q.9Easy

Which of the following is NOT a valid C# variable name?

Q.10Easy

What will be the output of the following code? string s = "Hello"; s = s + " World"; Console.WriteLine(s);

Q.11Medium

Which of the following correctly declares a nullable integer in C#?

Q.12Medium

What is the output of the following code? bool result = (5 > 3) && (2 < 1); Console.WriteLine(result);

Q.13Medium

Which keyword is used to prevent a class from being inherited in C#?

Q.14Medium

What will happen when you try to access an array index that is out of bounds in C#?

Q.15Hard

Consider the following code. What will be the output? int x = 10; int y = 20; int z = x++ + ++y; Console.WriteLine(x + " " + y + " " + z);

Q.16Hard

Which of the following statements about structs and classes in C# is TRUE?

Q.17Easy

Which of the following is a value type in C#?

Q.18Easy

What is the default access modifier for a class member in C#?

Q.19Easy

Which of the following correctly declares a variable that can hold null?

Q.20Easy

What will be the output of: Console.WriteLine();