Collections Flashcards
Which invocation of the remove(some args) method throws Exception?
Eg.., remove(100). If the list doesnt contains 100 elements, this invocation throws IndexOutOfBoundException
remove(object), if that object doesnt exists, returns false instead of throwing an exception
For which purposes ArrayList is very good?
Lookup of element at constant time.
Adding or removing of element is slower than accessing the element
What is LinkedList?
It implements both List and Queue.
Main benefit of LinkedList?
access, add or remove element from both the beginning and end of the list
Which classes does the Stack extends?
Stack extends Vector
Treeset implement which Set other than Set?
NavigableSet interface
What are the methods that NavigableSet interface provides?
lower(E e), floor(E e), ceiling(E e), higher(E e)
When do we use Queue?
When we want element to be added or removed in specified order
What is special about double-endede Queue?
We can insert/remove elements from both the front and back of the queue.
What is ArrayDeque?
It is a pure double-ended Queue.
It stores its element in resizeable array
The methods that are available in the ArrayDeque and used in stack are?
push, peek, pop
What is HashMap?
HashMap stores the key in hash tables. This means that it uses hashCode() method of keys to retrieve their values more efficiently
Treemap
Stores the Key in sorted tree structure
How to get a set of all keys in a map?
calling keySet()
How to get collection of all values?
values()