This quiz is designed to test your knowledge of accessing, sorting, and manipulating arrays in C#. You’ll encounter questions on how to work with multidimensional arrays, jagged arrays, array iteration, and the use of methods like Array.Sort()
, Array.Reverse()
, and Array.Clear()
. Additionally, you’ll explore concepts such as array indexing, the use of the Range
operator, and how to manipulate arrays in C#. This is a great way to solidify your understanding of array handling in C#.
1.
How do you use the index from end (^) operator to access the last element in an array?
2.
How can you determine the number of dimensions in a 3D array named 'my3Darray'?
3.
What does the Array.Sort() method do when called on a string array?
4.
Which operator in C# is used to specify an index from the end of an array?
5.
In the following code, what will be the value of subset1?
string[] subset1 = sentence[^7..^4];
6.
What does the following code return?
string[] words = sentence[4..7];
7.
How do you access the number of dimensions in a multidimensional array in C#?
8.
What would be the result of the following code?
Array.Clear(myArray, 1, 3);
9.
What does the Array.Clear() method do in C#?
10.
How can you reverse the order of elements in a C# array?
11.
What method is used to sort elements in a C# array?
12.
Which of the following statements will reverse the order of elements in an array?
13.
What does the following code do?
14.
How do you clear elements from an array in C#?
15.
What does the Rank property of an array indicate?
16.
What happens if you attempt to access an element at an index greater than the size of the array?
17.
How do you access elements of a multidimensional array?
18.
How does the Array.Sort() method work in C#?
19.
What is the output of the following code?
string[] colors = ["red", "blue"];
Array.Clear(colors, 1, 1);
Console.WriteLine(colors[1]);
20.
How do you reverse the order of an array in C#?
21.
What does the expression array[^2] return?
22.
How can you extract a range of elements from index 4 to 6 in an array using the range operator?
23.
What does the C# 'foreach' loop do when applied to an array?
24.
What output does the following code generate?
char[,,] my3Darray =
{
{
{ 'X', 'Y', 'Z' },
{ 'Q', 'U', 'R' }
},
{
{ 'L', 'M', 'N' },
{ 'D', 'E', 'F' }
}
};
Console.WriteLine(my3Darray[1,1,2]);
25.
Which of the following code snippets would access the first element in a two-dimensional array?
26.
How do you change the value of the first element in an array?
27.
How can you access the second element of an array named 'myArray'?