Skip to content
Sharp

Collections · interview question

How do you create an ArrayList with an initial capacity of 10?

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

Correct answer

B. New ArrayList<Integer>(10);

Why

The constructor new ArrayList<Integer>(10) creates an ArrayList with an initial capacity of 10, allowing room for growth without immediate resizing.

Test yourself on Collections

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

Start free test
All Collections questions →