Q1: What is the output of: int x = 10; if(x > 5) Console.Write("OK");?
NO
OK
10
Error
Q2: Which keyword is used to execute a block when a condition is false?
if
else
switch
case
Q3: How many times will this loop execute? for(int i=0;i<3;i++)
2
3
4
Infinite
Q4: Which loop checks the condition before executing the loop body?
do-while
while
foreach
loop
Q5: Which loop executes at least once even if the condition is false?
for
while
do-while
foreach
Q6: How do you declare an integer array of size 5 in C#?
int arr(5);
int arr[5];
int[] arr = new int[5];
array int arr = 5;
Q7: Array index in C# starts from:
-1
0
1
Depends on size
Q8: Which keyword is used to define a method in C#?
function
method
void
def
Q9: What is the return type of a method that returns nothing?
null
int
void
empty
Q10: Which OOP concept allows wrapping data and methods together?
Inheritance
Encapsulation
Polymorphism
Abstraction
Q11: Which keyword is used to inherit a class in C#?
implements
inherits
extends
:
Q12: Can a C# class inherit multiple classes?
Yes
No
Only abstract classes
Only interfaces
Q13: Which keyword is used to define an abstract class?
virtual
abstract
interface
static
Q14: Which member can an abstract class contain?
Only abstract methods
Only fields
Abstract and non-abstract methods
Only static methods
Q15: Which keyword is used to implement an interface?
implements
inherits
:
interface
Q16: What is a generic in C#?
A class with no methods
A type that works with any data type
A static class
An interface only
Q17: Which symbol is used to define a generic type?
[ ]
( )
< >
{ }
Q18: What is the correct way to declare a generic class?
class MyClass<T>
class MyClass(T)
class<T> MyClass
generic class MyClass
Q19: What is a delegate in C#?
A class that holds data
A method container
A reference type for methods
An interface
Q20: Which keyword is used to declare a delegate?
function
event
delegate
action
Q21: What is an event in C#?
A method
A variable
A notification mechanism
A class
Q22: Which keyword is used to declare an event?
notify
delegate
event
raise
Q23: Which LINQ method filters elements based on a condition?
Select()
Where()
OrderBy()
GroupBy()
Q24: Which LINQ method projects elements into a new form?
Where()
Select()
Join()
Any()
Q25: What does the LINQ method First() return?
All elements
The last element
The first element
A collection
Q26: Which statement correctly uses foreach?
foreach(int i in arr)
foreach i in arr
foreach(arr as i)
foreach(int i : arr)
Q27: Which access modifier allows access within the same assembly only?
public
private
internal
protected
Q28: Which keyword prevents a class from being inherited?
sealed
static
abstract
readonly
Q29: What is method overloading?
Same method name, different parameters
Same method name, same parameters
Different method names
Overriding methods
Q30: Which keyword is used to override a virtual method?
new
override
virtual
base
Q31: What is the default access modifier for class members in C#?
public
private
protected
internal
Q32: Which keyword allows a method to be overridden?
override
new
virtual
sealed
Q33: Which OOP concept means many forms?
Encapsulation
Inheritance
Polymorphism
Abstraction
Q34: Which class cannot be instantiated?
Sealed class
Abstract class
Static method
Normal class
Q35: Which interface member is allowed?
Fields
Constructors
Abstract methods
Destructors
Q36: What is boxing in C#?
Converting object to value type
Converting value type to object
Casting between classes
Using generics
Q37: What is unboxing?
Object to value type
Value type to object
Generic casting
Delegate call
Q38: Which collection works with key-value pairs?
List
Array
Dictionary
Queue
Q39: Which keyword is used to handle exceptions?
throw
catch
try
All of the above
Q40: Which block is always executed in exception handling?
try
catch
throw
finally
Q41: Which LINQ method checks if any element exists?
All()
Any()
Where()
Select()
Q42: Which LINQ method sorts data in ascending order?
OrderBy()
Sort()
GroupBy()
ThenBy()
Q43: What does IEnumerable represent?
A collection that can be iterated
A database table
A single object
A class only
Q44: Which keyword allows deferred execution in LINQ?
select
yield
return
await
Q45: Which statement correctly declares a lambda expression?
(x) => x * 2
x -> x * 2
function(x){return x*2;}
lambda x: x*2
Q46: What does the keyword static mean in C#?
Belongs to object
Belongs to class
Can be overridden
Can be inherited only
Q47: Which method is the entry point of a C# program?
Start()
Run()
Main()
Program()
Q48: Which keyword is used to create an object?
create
new
object
class
Q49: What is constructor used for?
Destroy object
Initialize object
Call methods
Override class
Q50: Which access modifier allows derived classes to access members?
private
public
protected
internal
Q51: Which keyword is used to free unmanaged resources?
delete
dispose
using
finalize
Q52: Which interface is used for resource cleanup?
ICloneable
IDisposable
IEnumerable
IComparable
Q53: Which keyword pauses execution until task completes?
wait
async
await
task
Q54: Which keyword marks a method as asynchronous?
await
thread
async
run
Q55: Which LINQ method groups elements?
Select()
GroupBy()
OrderBy()
Where()
Q56: Which LINQ method returns count of elements?
Any()
Sum()
Count()
Max()
Q57: What does var keyword do?
Declares dynamic variable
Infers type at compile time
Creates object
Declares constant
Q58: Which keyword is used to define a constant?
readonly
static
const
final
Q59: Which statement terminates a loop immediately?
continue
exit
break
return
Q60: Which keyword skips the current loop iteration?
break
pass
continue
skip
Q61: What is the output?
int score = 78;
if (score >= 90)
Console.Write("A");
else if (score >= 75)
Console.Write("B");
else
Console.Write("C");
A
B
C
Error
Q62: Which statement correctly checks whether an integer n is outside the range 1 to 100?
n < 1 && n > 100
n <= 1 || n >= 100
n < 1 || n > 100
!(n > 1 && n < 100)
Q63: What is printed?
int x = 3;
switch(x)
{
case 1:
case 2:
Console.Write("Low");
break;
case 3:
Console.Write("Mid");
break;
default:
Console.Write("High");
break;
}
Low
Mid
High
Nothing
Q64: Which loop is most appropriate when the number of iterations is known before execution?
while
do...while
for
foreach
Q65: What is the value of sum?
int sum = 0;
for(int i=2;i<=6;i+=2)
sum += i;
6
9
12
15
Q66: How many times will the loop execute?
int i = 5;
while(i > 0)
{
i -= 2;
}
2
3
4
5
Q67: Which statement initializes every element of an integer array to 100?
arr.Fill(100);
Array.Fill(arr,100);
Fill(arr,100);
arr.Set(100);
Q68: Which expression returns the number of rows in a two-dimensional array arr?
arr.Length
arr.GetLength(0)
arr.GetLength(1)
arr.Rows
Q69: Which expression returns the number of columns in a two-dimensional array arr?
arr.Length
arr.GetLength(1)
arr.GetLength(0)
arr.Columns
Q70: Which method parameter modifier allows a method to return multiple values by modifying the arguments?
params
out
this
in
Q71: Which keyword passes an argument by reference so its current value must already be initialized?
out
params
ref
this
Q72: What is the main purpose of a constructor with parameters?
Delete an object
Initialize object data during creation
Override methods
Destroy resources
Q73: Which keyword refers to the current object instance?
self
this
base
current
Q74: Which keyword calls a constructor of the base class?
parent
base
super
this
Q75: Which OOP principle allows a derived class to reuse members of its base class?
Abstraction
Inheritance
Encapsulation
Composition
Q76: Which keyword hides a base class member instead of overriding it?
override
virtual
new
sealed
Q77: Which declaration defines an auto-implemented property?
public int Age;
public int Age { get; set; }
property int Age;
int Age()
Q78: Which property accessor makes a property read-only from outside the class?
private get;
private set;
protected get;
internal get;
Q79: Which interface allows an object to be used in a foreach loop?
IDisposable
IEnumerable
IComparable
ICloneable
Q80: Which LINQ method returns the largest value in a numeric sequence?
Average()
Max()
First()
Last()
Q81: Which feature allows a derived class to provide its own implementation of a virtual method?
Method Hiding
Method Overriding
Method Overloading
Method Chaining
Q82: What will be printed?
class Animal
{
public virtual string Sound() => "Animal";
}
class Dog : Animal
{
public override string Sound() => "Bark";
}
Animal a = new Dog();
Console.Write(a.Sound());
Animal
Dog
Bark
Error
Q83: Which keyword prevents further overriding of an overridden method?
virtual
sealed
override
readonly
Q84: Which statement about abstract methods is correct?
They must contain a body.
They can only appear inside interfaces.
They must be implemented by derived concrete classes.
They are automatically static.
Q85: A class implements two interfaces. How many interfaces can a C# class implement?
Only one
Two
Up to five
Any number
Q86: Which declaration correctly defines a read-only auto property initialized in the constructor?
public int Id { get; }
public int Id { set; }
public int Id();
public int Id;
Q87: Which accessor is required for a writable property?
get
set
init
value
Q88: Which keyword represents the value being assigned inside a property setter?
this
data
value
set
Q89: What is the primary purpose of an indexer?
To overload operators
To allow object indexing like an array
To create events
To inherit classes
Q90: Which keyword is used when declaring an indexer?
index
this
self
base
Q91: Which statement correctly declares a delegate?
dele int Calc(int x,int y);
delegates int Calc(int x,int y);
deleg int Calc(int x, int y);
delegate int Calc(int x, int y);
Q92: A delegate can reference:
Only one static method
Methods with compatible signatures
Only constructors
Only abstract methods
Q93: Which operator adds another method to a multicast delegate?
=
+
+=
*=
Q94: Why are events preferred over exposing delegates directly?
Events consume less memory.
Events restrict external invocation.
Events execute faster.
Events require no delegates.
Q95: Which keyword removes an event handler?
-=
remove
delete
unsubscribe
Q96: Which LINQ method returns true only if every element satisfies a condition?
Any()
Exists()
All()
Contains()
Q97: Which LINQ method removes duplicate values from a sequence?
Unique()
Distinct()
Except()
Remove()
Q98: Which LINQ method calculates the average of numeric values?
Sum()
Average()
Mean()
Count()
Q99: Which LINQ method combines two sequences based on matching keys?
Concat()
Join()
Union()
Zip()
Q100: Which LINQ method combines two sequences while removing duplicate elements?
Concat()
Union()
Append()
Intersect()
Q101: What is the output?
Func square = x => x * x;
Console.Write(square(4));
4
8
16
Error
Q102: Which built-in delegate represents a method that has no return value and no parameters?
Func
Predicate
Action
EventHandler
Q103: Which built-in delegate represents a method that returns a value?
Action
Func
EventHandler
Comparison
Q104: Which built-in delegate always returns a bool value?
Func
Predicate
Action
EventHandler
Q105: Which keyword is typically used to invoke an event safely?
invoke
raise
?.
call
Q106: Which statement subscribes to an event named Click?
Click = Handler;
Click += Handler;
Click <- Handler;
Click == Handler;
Q107: Which statement correctly declares an indexer?
public int this[int index] { get; set; }
public int index[int i] { get; set; }
public this[int i] { get; set; }
public int Item(int i) { get; set; }
Q108: What is the output?
int[] a = {4,1,3,2};
Console.Write(a.Max());
1
2
3
4
Q109: Which LINQ method returns the smallest value in a sequence?
Lowest()
Min()
First()
Bottom()
Q110: Which LINQ method calculates the total of numeric values?
Count()
Average()
Sum()
Aggregate()
Q111: Which LINQ method returns the last element of a sequence?
End()
Last()
Tail()
Final()
Q112: Which LINQ method returns the first element or a default value if the sequence is empty?
First()
Default()
FirstOrDefault()
Single()
Q113: Which LINQ method determines whether a sequence contains a specified element?
Exists()
Any()
Contains()
Find()
Q114: Which LINQ method skips the first n elements?
Take()
Skip()
Remove()
Drop()
Q115: Which LINQ method returns only the first n elements?
Skip()
Take()
Select()
Range()
Q116: Which LINQ method concatenates two sequences without removing duplicates?
Union()
Concat()
Merge()
AppendAll()
Q117: Which keyword allows one interface to inherit another interface?
extends
implements
:
inherits
Q118: Which statement about interfaces is correct?
An interface can inherit multiple interfaces.
An interface can inherit only one interface.
Interfaces cannot inherit.
Interfaces can inherit classes.
Q119: Which keyword allows a derived class to access a hidden member of its base class?
this
parent
base
super
Q120: Which OOP principle focuses on exposing only essential features while hiding implementation details?
Encapsulation
Inheritance
Polymorphism
Abstraction
Bản quyền thuộc về V1Study.com. Cấm sao chép dưới mọi hình thức!