Which of the following are true about an
ArrayList
? (Select all that apply)
ArrayLists have a dynamic size.
Correct: Unlike partially-filled arrays, ArrayLists automatically resize themselves when an element is added or removed.
ArrayLists have a fixed size.
Incorrect: ArrayLists resize automatically when an element is added or removed while partially-filled arrays require manual resizing if you have reached capacity and are trying to add an element.
ArrayLists use the .length()
method to get the number of elements in the list.
Incorrect: ArrayLists use .size()
while arrays use .length()
.
ArrayLists cannot be instantiated without importing from the Java Library.
Correct: To use ArrayLists, you must import the java.util.ArrayList package first.