Core Java Interview Questions: ArrayList, LinkedList, and Vector
This Core Java Interview Questions post provides all the interview questions about ArrayList, LinkedList, and Vector including differences between ArrayList, LinkedList and Vector, Synchronized list, non-synchronized lists, advantages and disadvantages and much more.
What are the examples of Synchronized collections?
Vector collection is the example of a Synchronized collection.
What is the default capacity of Vector?
The initial capacity in the definition of Vector, it is ten.
What is the difference between ArrayList and Vector?
Vector is synchronized whereas ArrayList is not.
Can we synchronize ArrayList explicitly?
What is the use of Enumeration interface?
Used to process the elements of Vector collection.
What are the advantages of ArrayList over LinkedList?
Accessing elements is faster in ArrayList because it is index based.
What are the advantages of LinkedList over ArrayList and Vector?
The only advantage of LinkedList is insertions and deletions are much faster.
No need to shift the elements in LinkedList in case of insertion as well as deletion.
What is the increment capacity of Vector?
Size will be doubled probably.
How can we iterate elements of ArrayList?
Using Iterator interface, for each loop.
What size() method returns in Collections?
Returns number of elements in the collection object.
Can we set capacity explicitly in Vector?
Yes allowed, we can set initial capacity based on application requirement.
How will objects store in LinkedList?
In the form of nodes.