C Sharp Arrays Questions and Answers

Practice Mode
Showing 10 of 30 questions
Q11
In C#, what is the index of the first element in an array?
  • A 0
  • B 1
  • C -1
  • D Depends on array declaration
Answer: Option A
Explanation: Array indices start from 0 in C#.
Q12
Which of the following correctly declares an array in C#?
  • A int array[];
  • B int[] array;
  • C array int[];
  • D array[] int;
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#?
  • A array.Length
  • B array.Count()
  • C array.Size
  • D array.Elements
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#?
  • A 0
  • B 1
  • C null
  • D random value
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#?
  • A Array.Sort()
  • B array.Sort()
  • C Sort(array)
  • D array.Order()
Answer: Option A
Explanation: Array.Sort() is the static method used for sorting arrays.
Q16
How do you declare a multidimensional array in C#?
  • A int[,] array;
  • B int[][] array;
  • C int[[]] array;
  • D int{} array;
Answer: Option A
Explanation: Multiple commas within square brackets define multidimensional arrays.
Q17
What is a jagged array in C#?
  • A Array of arrays with different sizes
  • B Single dimensional array
  • C Fixed size multidimensional array
  • D Array with jagged edges
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?
  • A Array.Copy()
  • B array.Copy()
  • C Array.Clone()
  • D array.Duplicate()
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?
  • A Array.Reverse()
  • B array.Reverse()
  • C Reverse(array)
  • D array.Flip()
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?
  • A IndexOutOfRangeException
  • B NullReferenceException
  • C ArrayException
  • D No error, returns default value
Answer: Option A
Explanation: Accessing beyond array bounds throws IndexOutOfRangeException.
Questions and Answers for Competitive Exams Various Entrance Test