Skip to content
Sharp

Collections · interview question

How does an ArrayList handle element removal in terms of performance?

Multiple choiceHardchapter-4-curatedpremiumcollectionslist-interface-and-arraylist
Choose one answer
Answer and explanation

Correct answer

D. It takes linear time O(n) in the worst case.

Why

Removing an element from an ArrayList typically involves shifting elements, leading to O(n) time complexity in the worst case, especially if the element is near the beginning.

Test yourself on Collections

A free test with instant, explained results. No account needed.

Start free test
All Collections questions →