Question 18
In addition to implementing the List interface, which of the following also provides methods to get, insert, and remove elements from the head and tail of the list?
a. Collection
b. ArrayList
c. LinkedList
d. List
e. Vector
f. None of the above
Answer:
c LinkedList The LinkedList provides methods that facilitate the implementation of stacks and queues.
I don't understand why
b and
e are incorrect? I think they also meet the requirements of the question:
1. ArrayList and Vector both implements the List interface
2. Both have the method
get that can get elements from head and tail. In addition, Vector has the methods
firstElement() and
lastElement.
3. Both have a method
add that can add elemenent at the beginning and end of the list
4. Both have a method
remove that can remove element at the beginning and end of the list.
So what am I missing?