Mention two benefits of using ArrayList over array in software development.
(Choose two options.)
Select one or more:
A. Reduces memory footprint
B. Implements the Collection API
C. Is multi.thread safe
D. Dynamically resizes based on the number of elements in the list
My answer was B & D . But the correct answer is A & D . I am aware that A is bit ambiguous here. I saw a post in coderanch about it.But my concern is not about A , It is about B. But how on earth is B wrong?
I think this kind of questions is one of the reasons why people prefer Enthuware above WhizLabs.
Do they provide an explanation of their own why B is wrong?
My opinion: If B would have been "Collection interface" there would be no discussion at all and B would be correct. If B would have been "Collection class" there would be also no discussion at all and B would be incorrect (Collection is an interface, not a class). An API usually defines a set of classes, and I guess that's why the answer is wrong.
How is A correct? It maybe correct in some situations but certainly isn't in all cases. For example if you have a given number of elements and the array is that exact size then it will have a smaller memory footprint than an ArrayList with the same number of elements.