
Data Structures MCQs – Arrays and Array
Operations
1. Which of these best describes an array?
a) A data structure that shows a hierarchical behavior
b) Container of objects of similar types
c) Arrays are immutable once initialised
d) Array is not a data structure
Answer: b
Explanation: Array contains elements only of the same type.
2. How do you initialize an array in C?
a) int arr[3] = (1,2,3);
b) int arr(3) = {1,2,3};
c) int arr[3] = {1,2,3};
d) int arr(3) = (1,2,3);
Answer: c
Explanation: Correct syntax uses curly braces {}.
3. How do you instantiate an array in Java?
a) int arr[] = new int(3);
b) int arr[];
c) int arr[] = new int[3];
d) int arr() = new int(3);
Answer: c
Explanation: Declaration vs instantiation difference.
4. Correct way to declare a multidimensional array in Java?
a) int[] arr;
b) int arr[[]];
c) int[][] arr;
d) int[[]] arr;
Answer: c
5. Output of arr[2] and arr[4] for {1,2,3,4,5}?
a) 3 and 5
b) 5 and 3
c) 2 and 4
d) 4 and 2
Answer: a
Explanation: Index starts from 0.
6. Output of accessing arr[5]?
a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InvalidInputException
Answer: c
7. When does ArrayIndexOutOfBoundsException occur?
a) Compile-time
b) Run-time
c) Not an error
d) Not an exception