C Sharp Arrays Questions and Answers
Practice ModeShowing 10 of 30 questions
Q11
In C#, what is the index of the first element in an array?
Answer: Option A
Explanation: Array indices start from 0 in C#.
Q12
Which of the following correctly declares an array in C#?
Answer: Option B
Explanation: Square brackets [] are used after the data type to declare arrays.
Q13
How do you get the number of elements in an array in C#?
Answer: Option A
Explanation: The Length property returns the total number of elements in an array.
Q14
What is the default value of numeric array elements in C#?
Answer: Option A
Explanation: Numeric types in arrays are initialized to 0 by default.
Q15
Which method is used to sort an array in C#?
Answer: Option A
Explanation: Array.Sort() is the static method used for sorting arrays.
Q16
How do you declare a multidimensional array in C#?
Answer: Option A
Explanation: Multiple commas within square brackets define multidimensional arrays.
Q17
What is a jagged array in C#?
Answer: Option A
Explanation: A jagged array is an array of arrays where each inner array can have different lengths.
Q18
Which of the following copies elements from one array to another?
Answer: Option A
Explanation: Array.Copy() method is used to copy elements between arrays.
Q19
How do you reverse the order of elements in an array?
Answer: Option A
Explanation: Array.Reverse() method reverses the order of elements in the entire array.
Q20
What happens when you try to access an array element with an index beyond its bounds?
Answer: Option A
Explanation: Accessing beyond array bounds throws IndexOutOfRangeException.