Entrance Exams
Govt. Exams
Collections.synchronizedMap() wraps a Map with synchronized access. However, iteration still requires external synchronization.
TreeMap.headMap(10) returns a view of all entries with keys strictly less than 10. It's exclusive of the provided key.
Fail-fast iterators throw ConcurrentModificationException if the collection is modified during iteration (except via iterator.remove()).
LinkedList provides O(1) operations for adding/removing at both ends via addFirst(), addLast(), removeFirst(), removeLast().
HashMap allows one null key which is handled specially and stored at index 0. TreeMap does not allow null keys.
The containsValue() method checks if the map contains a specified value. containsKey() checks for keys.
HashMap has an initial capacity of 16 and doubles its capacity when load factor (0.75) is reached.
No collection allows duplicate keys. When a duplicate key is added to a Map, it overwrites the previous value. HashSet and TreeSet don't allow duplicates.
Collections.unmodifiableList() returns a read-only view of the list. Any modification attempts throw UnsupportedOperationException.
The Comparable interface allows objects to define their natural ordering by implementing compareTo() method.