Govt Exams
TreeSet is backed by a TreeMap which uses Red-Black tree. Add operation requires O(log n) time for tree balancing.
Set interface implementations like HashSet do not allow duplicates. Lists (ArrayList, LinkedList, Vector) allow duplicates.
Load factor is the ratio of size to capacity. Default load factor in HashMap is 0.75, which provides good balance between time and space complexity.
Using remove() directly in loop causes ConcurrentModificationException. Iterator.remove() is the safe way to remove elements while iterating.
ArrayList is backed by a resizable array providing O(1) random access. LinkedList uses doubly-linked list providing O(1) insertion/deletion at ends but O(n) for random access.
LinkedHashSet maintains insertion order using doubly-linked list. HashSet doesn't maintain order, TreeSet maintains sorted order, HashMap doesn't maintain insertion order.
HashMap provides O(1) average time complexity for get() operation. In worst case with hash collisions, it can be O(n).
HashMap implements the Map interface which stores key-value pairs. It does not implement Collection, List, or Set interfaces directly.
The @Override annotation helps verify that you are correctly overriding a parent method and improves code clarity, but it does NOT automatically invoke the parent class method. You must use super.methodName() for that. @Override is purely a compile-time marker for verification purposes.
The same withdraw() call behaves differently for SavingsAccount and CurrentAccount based on the actual object type at runtime. This is polymorphism with runtime (dynamic) binding.