Singly Link List
Singly Link List
Operations
This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on
“Array and Array Operations”.
Answer: b
Explanation: Array contains elements only of the same type.
Answer: c
Explanation: This is the syntax to initialize an array in C.
Answer: c
Explanation: Note that int arr[]; is declaration whereas int arr[] = new int[3]; is to
instantiate an array.
advertisement
advertisement
4. Which of the following is the correct way to declare a multidimensional array in Java?
a) int[] arr;
b) int arr[[]];
c) int[][]arr;
d) int[[]] arr;
View Answer
Answer: c
Explanation: The syntax to declare multidimensional array in java is either int[][] arr; or
int arr[][];
a) 3 and 5
b) 5 and 3
c) 2 and 4
d) 4 and 2
View Answer
Answer: a
Explanation: Array indexing starts from 0.
advertisement
a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InavlidInputException
View Answer
Answer: c
Explanation: Trying to access an element beyond the limits of an array gives
ArrayIndexOutOfBoundsException.
advertisement
Answer: b
Explanation: ArrayIndexOutOfBoundsException is a run-time exception and the
compilation is error-free.
Answer: d
Explanation: Whenever a particular memory location is referred to, it is likely that the
locations nearby are also referred, arrays are stored as contiguous blocks in memory,
so if you want to access array elements, spatial locality makes it to access quickly.
Answer: d
Explanation: Arrays store elements of the same data type and present in continuous
memory locations.
Answer: b
Explanation: Arrays are of fixed size. If we insert elements less than the allocated
size, unoccupied positions can’t be used again. Wastage will occur in memory.
Answer: d
Explanation: Since there are 15 int elements and each int is of 4bytes, we get 15*4 =
60bytes.
Answer: a
Explanation: Elements in an array are accessed randomly. In Linked lists, elements
are accessed sequentially.