Q1.
Which of the following is true about C#?
1
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
Q2.
What is the default access modifier for a class in C#?
1
1
Internal
2
Private
3
public
4
Protected
Q3.
Which of the following is NOT a valid C# data type?
1
1
real
2
int
3
double
4
float
Q4.
What is the output of the following C# code?
int a = 5, b = 2; double result = a / b; Console.WriteLine(result);
1
1
2.5
2
Compilation error
3
2
4
2.0
Q5.
Which of the following statements about C# constructors is true?
1
1
A class can have only one constructor
2
A constructor must always have a return type
3
A constructor is automatically called when an object is created
4
A constructor can be called explicitly like a normal method
Q6.
What is the keyword used to inherit a class in C#?
1
1
implements
2
extends
3
: (colon)
4
inherits
Q7.
What is the difference between == and .Equals() in C#?
1
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
Q8.
Which of the following statements about C# interfaces is true?
1
1
An interface can have fields
2
An interface can provide default method implementation
3
An interface cannot be inherited by another interface
4
An interface can contain constructors
Q9.
What is the purpose of the using statement in C#?
1
1
It imports namespaces
2
It defines scope for disposing objects
3
It handles exceptions
4
Both 1 and 2
Q10.
What is the correct way to define a nullable integer in C#?
1
1
int? num = null;
2
nullable<int> num = null;
3
int num = nullable;
4
null int num;
Q11.
Which of the following is true about C# properties?
1
1
Properties can have different access modifiers for get and set
2
Properties must always have both get and set
3
Properties cannot be read-only
4
Properties are just variables with additional syntax
Q12.
Which keyword is used to prevent a class from being inherited?
1
1
sealed
2
static
3
private
4
abstract
Q13.
What will happen if you call ToString() on a null object in C#?
1
1
It returns an empty string
2
It throws a NullReferenceException
3
It returns "null"
4
It depends on the object's type
Q14.
Which of the following statements about Dictionary in C# is true?
1
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
Q15.
What type of inheritance is not supported in C#?
1
1
Single Inheritance
2
Multilevel Inheritance
3
Multiple Inheritance
4
Hierarchical Inheritance
Q16.
Which of the following is true about abstract classes in C#?
1
1
Abstract classes can be instantiated.
2
Abstract classes must have at least one abstract method.
3
An abstract class can have concrete methods.
4
Interfaces and abstract classes are the same.
Q17.
Which keyword prevents method overriding in C#?
1
1
final
2
sealed
3
private
4
abstract
Q18.
Which language influenced the development of C# the most?
1
1
C++
2
Python
3
Java
4
PHP
Q19.
What is the primary runtime used to execute C# programs?
1
1
Java Virtual Machine (JVM)
2
Dynamic Link Library (DLL)
3
Common Language Runtime (CLR)
4
Common Runtime Interface (CRI)
Q20.
If you receive a 'namespace not found' error, what is the likely cause?
1
1
Incorrect file extension
2
Typo in the class name
3
Missing 'using' directive
4
Missing semicolon