Govt Exams
ReentrantReadWriteLock provides separate read and write locks, allowing multiple readers but only one writer, offering finer-grained control than basic synchronized constructs.
In Kafka, the maximum number of active consumers in a group equals the number of partitions. With 8 partitions and 5 consumers, only 3 will remain idle.
When the load factor (ratio of entries to capacity) exceeds the threshold, the HashMap is rehashed with approximately double the capacity to maintain performance.
CAP theorem states that distributed systems can guarantee only two out of three properties: Consistency, Availability, and Partition Tolerance.
When wait() is called in a synchronized block, the thread releases the object lock and enters a waiting state until notify() or notifyAll() is called.
A deadlock occurs when two or more processes are blocked forever, each holding resources the other needs, causing circular dependency.
Interface Segregation Principle states that clients should not depend on interfaces they don't use. Multiple unrelated interfaces violate this.
Hash map provides O(1) access while doubly linked list maintains order. Combined they achieve O(1) for all LRU operations.
Dijkstra's algorithm is the optimal choice for finding shortest paths in weighted graphs with non-negative weights, with O(E log V) complexity.
Dynamic programming requires defining subproblems, establishing recurrence relations, and implementing solutions using memoization or tabulation for optimization.