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.3Easy

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

Q.4Easy

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

Q.5Easy

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

Q.6Easy

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

Q.7Easy

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

Q.8Easy

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

Q.9Easy

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

Q.10Easy

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

Q.11Easy

What is the correct syntax for a multi-line comment in C#?

Q.12Easy

Which keyword is used to create a constant variable in C# that cannot be modified after initialization?

Q.13Easy

What will be the output of: int x = 10; int y = 20; int z = x > y ? x : y; Console.WriteLine(z);

Q.14Easy

What is the output of: decimal d = 10.5m; int x = (int)d; Console.WriteLine(x);

Q.15Easy

In C#, which keyword is used to create a constant variable that cannot be modified after initialization?

Q.16Easy

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

Q.17Easy

Which namespace must be included to use LINQ in C#?

Q.18Easy

In C#, what is the correct syntax to declare a nullable integer?

Q.19Easy

What will be printed when the following code executes? string str = "Hello"; str = str + " World"; Console.WriteLine(str.Length);

Q.20Easy

In C#, which keyword is used to declare a variable that cannot be changed after initialization?