Question 1
Which of the following is true about C#?
1
C# is a statically-typed language
2
C# supports multiple inheritance directly
3
C# does not support garbage collection
4
C# does not support object-oriented programming
5
None of the above
Question 2
What is the default access modifier for a class in C#?
1
Private
2
Internal
3
Protected
4
public
Question 3
Which of the following is NOT a valid C# data type?
1
int
2
float
3
real
4
double
Question 4
What is the output of the following C# code?
int a = 5, b = 2; double result = a / b; Console.WriteLine(result);
1
2
2
Compilation error
3
2.5
4
2.0
Question 5
Which of the following statements about C# constructors is true?
1
A constructor can be called explicitly like a normal method
2
A constructor is automatically called when an object is created
3
A constructor must always have a return type
4
A class can have only one constructor
Question 6
What is the keyword used to inherit a class in C#?
1
extends
2
: (colon)
3
inherits
4
implements
Question 7
What is the difference between == and .Equals() in C#?
1
Both are the same and compare object references
2
== compares values, whereas .Equals() compares references
3
== compares references, whereas .Equals() compares values
4
None of the above
Question 8
What will be the output of the following code?
string s1 = "Hello"; string s2 = "Hello"; Console.WriteLine(s1 == s2); Console.WriteLine(s1.Equals(s2));
1
True True
2
False True
3
True False
4
False False
Question 9
Which of the following statements about C# interfaces is true?
1
An interface cannot be inherited by another interface
2
An interface can have fields
3
An interface can provide default method implementation
4
An interface can contain constructors
Question 10
What is the purpose of the using statement in C#?
1
It imports namespaces
2
It defines scope for disposing objects
3
It handles exceptions
4
Both 1 and 2
Question 11
What is the output of the following C# code?
using System; class Program { static void Main() { int x = 10; object obj = x; int y = (int)obj; Console.Write(y); } }
1
NullReferenceException
2
10
3
Runtime error
4
Compilation error
Question 12
What is the correct way to define a nullable integer in C#?
1
nullable<int> num = null;
2
int? num = null;
3
int num = nullable;
4
null int num;
Question 13
Which of the following is true about C# properties?
1
Properties must always have both get and set
2
Properties can have different access modifiers for get and set
3
Properties are just variables with additional syntax
4
Properties cannot be read-only
Question 14
Which keyword is used to prevent a class from being inherited?
1
sealed
2
private
3
abstract
4
static
Question 15
Which of the following correctly implements an interface in C#?
1
interface ITest { void Show(); } class MyClass : ITest { public void Show() { Console.WriteLine("Hello"); } }
2
interface ITest { void Show(); } class MyClass : ITest { void Show() { Console.WriteLine("Hello"); } }
3
interface ITest { void Show(); } class MyClass : ITest { protected void Show() { Console.WriteLine("Hello"); } }
4
interface ITest { void Show(); } class MyClass { public void Show() { Console.WriteLine("Hello"); } }
Question 16
What will be the output of the following LINQ query?
var numbers = new List<int> { 2, 3, 4, 5 }; var result = numbers.Where(n => n % 2 == 0); Console.WriteLine(result.Count());
1
3
2
4
3
1
4
2
Question 17
What will happen if you call ToString() on a null object in C#?
1
It returns an empty string
2
It throws a NullReferenceException
3
It depends on the object's type
4
It returns "null"
Question 18
What is the output of the following C# code?
async Task<int> GetNumberAsync() { return 5; } async Task Main() { Task<int> task = GetNumberAsync(); Console.WriteLine("Before await"); int result = await task; Console.WriteLine($"Result: {result}"); }
1
Result: 5 Before await
2
Compilation error
3
Before await Result: 5
4
Random execution order
Question 19
Which of the following statements about Dictionary in C# is true?
1
Keys in a dictionary must be unique
2
A dictionary allows only string keys
3
A dictionary stores elements in a sorted order
4
All of the above
Question 20
What type of inheritance is not supported in C#?
1
Multiple Inheritance
2
Multilevel Inheritance
3
Hierarchical Inheritance
4
Single Inheritance
Question 21
Which of the following is true about abstract classes in C#?
1
Abstract classes must have at least one abstract method.
2
Interfaces and abstract classes are the same.
3
Abstract classes can be instantiated.
4
An abstract class can have concrete methods.
Question 22
Which keyword prevents method overriding in C#?
1
abstract
2
private
3
sealed
4
final
Question 23
Which of the following best describes the .NET framework?
1
A hardware component
2
An operating system
3
A development platform
4
A database management system
Question 24
Which language influenced the development of C# the most?
1
Java
2
PHP
3
Python
4
C++
Question 25
What is the primary runtime used to execute C# programs?
1
Common Runtime Interface (CRI)
2
Java Virtual Machine (JVM)
3
Common Language Runtime (CLR)
4
Dynamic Link Library (DLL)
Question 26
If you receive a 'namespace not found' error, what is the likely cause?
1
Missing 'using' directive
2
Incorrect file extension
3
Typo in the class name
4
Missing semicolon
Question 27
What will be the output of the following code?
int a = 5, b = 2; Console.WriteLine(a / b);
1
2
2
3
3
Error
4
2.5
Question 28
Which operator has the highest precedence in C#?
1
+
2
()
3
*
4
=
Question 29
What does the ?? operator do in C#?
1
Checks equality
2
Performs null-coalescing
3
Performs bitwise OR
4
Checks type
Question 30
What is the result of this expression: true || false && false?
1
Cannot determine
2
true
3
Error
4
false