Skip to content
Sharp

Core Java · interview question

How would you explain the time complexity for retrieving an element by index from an ArrayList in an interview?

Multiple choiceMediumchapter-4-curatedpremiumcore-javacode-reading-with-collections
Choose one answer
Answer and explanation

Correct answer

D. O(1)

Why

ArrayList is implemented with a dynamic array, allowing constant time complexity O(1) for accessing elements by index.

Test yourself on Core Java

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

Start free test
All Core Java questions →