Recall & Review
beginner
What is the starting index of arrays in C#?
Arrays in C# start indexing at 0. This means the first element is at index 0, the second at index 1, and so on.
Click to reveal answer
beginner
How do you access the third element of an array named
numbers?You access it using
numbers[2] because indexing starts at 0.Click to reveal answer
intermediate
What happens if you try to access an index outside the array bounds in C#?
You get a
System.IndexOutOfRangeException error because the index is invalid.Click to reveal answer
beginner
How can you find the length of an array named
items?Use
items.Length to get the number of elements in the array.Click to reveal answer
beginner
Explain how to change the value of the first element in an array
colors to "red".Assign the new value using
colors[0] = "red"; to update the first element.Click to reveal answer
What is the index of the last element in an array with 10 elements?
✗ Incorrect
Since indexing starts at 0, the last element is at index 9 (10 - 1).
Which of the following accesses the second element of an array named
arr?✗ Incorrect
The second element is at index 1 because indexing starts at 0.
What property gives the number of elements in a C# array?
✗ Incorrect
The
Length property returns the number of elements in the array.What error occurs if you try to access
array[10] when the array has 10 elements?✗ Incorrect
Accessing index 10 is out of bounds since valid indices are 0 to 9, causing an IndexOutOfRangeException.
How do you change the value of the first element in an array named
data?✗ Incorrect
You assign the new value directly using the index:
data[0] = newValue;.Describe how array indexing works in C# and how to access elements safely.
Think about how you count positions starting from zero.
You got /4 concepts.
Explain how to update an element in a C# array and what happens if you try to access an invalid index.
Consider what happens if you try to open a door that doesn't exist.
You got /2 concepts.