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#?
2 How do you access the third element in an array named 'scores'?
3 What does Array.Length return?
4 Which loop is best for iterating through an array when you don't need the index?
5 How do you create a new List of strings in C#?
6 Which method adds an item to a List?
7 What property gives you the number of items in a List?
8 What is the key difference between an array and a List?
9 What will this code output? int x = 10; if (x > 5) { Console.Write('A'); } else { Console.Write('B'); }
10 Which operator is used for AND in C#?
11 What is the correct syntax for an else-if statement?
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'); }
13 What keyword is used to end a case in a switch statement?
14 What is the default case in a switch statement?
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; }
16 What does the default case do in a switch statement?
17 Which loop is best when you know exactly how many times to iterate?
18 Which loop always executes the code block at least once?
19 What does the continue statement do in a loop?
20 What is the difference between a for loop and a foreach loop?