What is the output of the following?
List<String> v = new ArrayList<>(1); v.add("A"); v.add("B"); v.add("Art"); v.remove(2); System.out.println(v);
A.
While the ArrayList is declared with an initial capacity of one element, it is free to expand as more elements are added.
Each of the three calls to the add()
method adds an element to the end of the ArrayList.
The remove()
method call deletes the element at index 2, which is Art.
Option A is correct.