Exams Knowledge Hub

MCQs for Competitive Exams, School & College Exams

Module: | Arrays, Strings & Exception Handling

Q59: Consider the following statements regarding ArrayList and LinkedList:

1. ArrayList utilizes a dynamic contiguous array, enabling random element access by numerical index as an ultra-fast O(1) time complexity operation.
2. LinkedList implements a doubly-linked list architecture, storing elements in widely scattered, non-contiguous memory nodes across the Heap.
3. When an element is removed from the absolute center of an ArrayList, the ArrayList automatically physically shrinks its overall memory capacity back down to match the exact remaining element count.

Which of the above statements is/are correct?
A
Only 1 and 2
B
Only 1 and 3
C
Only 2 and 3
D
1, 2, and 3
✅ Correct Answer: A
🎯 Quick Answer:
The correct combination is 1 and 2. Statement 3 is incorrect because removing an element from an ArrayList merely shifts the subsequent elements to the left to fill the gap. The underlying array's physical memory capacity remains identically massive until the developer explicitly invokes the trimToSize() method.
Concept Definition: ArrayList and LinkedList are the two primary concrete implementations of the List interface, offering fundamentally different underlying architectures for ordered data storage.
Structural Breakdown: ArrayList wraps a standard Java array, dynamically creating a 50% larger array and copying data over when it gets full.
LinkedList creates standalone Node objects containing the data, a pointer to the previous node, and a pointer to the next node.
Historical/Related Context: The choice between these two is a staple in university data structure exams.
ArrayList is overwhelmingly dominant in read-heavy applications (99% of enterprise use cases) due to its CPU cache locality.
LinkedList was historically preferred for write-heavy applications where elements were constantly inserted or deleted from the middle of the list.
Causal Reasoning: ArrayList achieves O(1) index access (Statement 1) because contiguous memory allows the JVM to use a simple mathematical formula (Base_Address + (Index * Element_Size)) to instantly locate any element's physical memory address without traversing the list sequentially.