C# Mastery Hub
Home
Challenges
Discussion
Lessons
Core Topics
C# Fundamentals
Console Applications
Classes & OOP
Windows Forms
ASP.NET Core
SQL Server
VS & SQL Connection
RDLC Reports
.NET MAUI
Getting Started
Getting Started
Website Development
SEO Guide
Security
Project Workflow
Extra Topics
Cloud & Deployment
AWS Cloud
Deployment
About
Contact
Test Your Knowledge
WindowsForms_Refresher Quiz
Answer all questions to test your understanding
1
What is the correct way to declare an array of 5 integers in C#?
int[] numbers = new int[5];
int numbers[5] = new int[];
array<int> numbers = new array<int>(5);
int[] numbers = new int[]{5};
2
How do you access the third element in an array named 'scores'?
scores[2]
scores[3]
scores.Third()
scores.Item(3)
3
What does Array.Length return?
The number of elements in the array
The memory size of the array
The index of the last element
The number of dimensions
4
Which loop is best for iterating through an array when you don't need the index?
foreach
for
while
do-while
5
How do you create a new List of strings in C#?
List<string> names = new List<string>();
string[] names = new List<string>();
List<string> names = new List();
new List<string> names = new List<string>();
6
Which method adds an item to a List?
Add()
Append()
Insert()
Push()
7
What property gives you the number of items in a List?
Count
Length
Size
Items
8
What is the key difference between an array and a List?
Lists can grow dynamically, arrays have fixed size
Arrays can store more data
Lists are faster than arrays
Arrays can store different types
9
What will this code output? int x = 10; if (x > 5) { Console.Write('A'); } else { Console.Write('B'); }
A
B
AB
Nothing
10
Which operator is used for AND in C#?
&&
&
and
AND
11
What is the correct syntax for an else-if statement?
else if (condition) { }
elsif (condition) { }
elseif (condition) { }
elif (condition) { }
12
What will this code output? int age = 15; if (age >= 18) { Console.Write('Adult'); } else if (age >= 13) { Console.Write('Teen'); } else { Console.Write('Child'); }
Teen
Adult
Child
Nothing
13
What keyword is used to end a case in a switch statement?
break
exit
end
return
14
What is the default case in a switch statement?
Runs when no other case matches
Runs first
Runs last
Is optional and runs always
15
What will this code output? string color = 'Red'; switch(color) { case 'Red': Console.Write('R'); break; case 'Blue': Console.Write('B'); break; default: Console.Write('?'); break; }
R
B
?
RB
16
What does the default case do in a switch statement?
Handles all unmatched values
Handles only the first value
Exits the switch
Throws an exception
17
Which loop is best when you know exactly how many times to iterate?
for
while
do-while
foreach
18
Which loop always executes the code block at least once?
for
while
do-while
foreach
19
What does the continue statement do in a loop?
Exits the loop entirely
Skips the current iteration
Restarts the loop
Throws an exception
20
What is the difference between a for loop and a foreach loop?
for uses an index, foreach works directly with elements
foreach uses an index, for works directly with elements
They are identical
for is only for arrays, foreach is for lists
Submit Quiz