Published on

Java Collections

Authors
Time yourself:
Your progress:

00:30:00

0%

List

1. Why are collections preferred over arrays in Java?

Flag important question
Mark as complete

2. What is the difference between ArrayList and LinkedList? When would you use each?

Flag important question
Mark as complete

3. How does the subList() method work in ArrayList?

Flag important question
Mark as complete

4. How does Vector ensure thread safety, and what are its drawbacks?

Flag important question
Mark as complete

5. What algorithm is used by these Java APIs Arrays.sort() and Collections.sort()?

Flag important question
Mark as complete

Set

6. How do HashMap and HashSet Work Internally?

Flag important question
Mark as complete

7. How does a HashSet ensure uniqueness of elements?

Flag important question
Mark as complete

8. If one needs a Set, how do you choose between HashSet vs. TreeSet?

Flag important question
Mark as complete

9. What is the difference between HashSet, LinkedHashSet, and TreeSet?

Flag important question
Mark as complete

10. How is iteration order maintained in LinkedHashSet?

Flag important question
Mark as complete

11. Can you store null values in a TreeSet? Why or why not?

Flag important question
Mark as complete

12. How does TreeSet maintain its sorting order?

Flag important question
Mark as complete

Map

13. Describe various implementations of the Map interface and their use case differences?

Flag important question
Mark as complete

14. How does LinkedHashMap maintain insertion order?

Flag important question
Mark as complete

15. What is the role of the load factor in HashMap?

Flag important question
Mark as complete

16. What is the difference between HashMap and Hashtable?

Flag important question
Mark as complete

17. Can you implement a LRU Cache using a LinkedHashMap?

Flag important question
Mark as complete

18. What is a WeakHashMap, and how does it handle garbage collection?

Flag important question
Mark as complete

19. How does ConcurrentHashMap achieve thread safety?

Flag important question
Mark as complete

Queue and Deque

20. What is the difference between Queue and Deque?

Flag important question
Mark as complete

21. How does a PriorityQueue determine element order?

Flag important question
Mark as complete

22. What are the use cases for ArrayDeque?

Flag important question
Mark as complete

23. How does a BlockingQueue handle producer-consumer scenarios?

Flag important question
Mark as complete

24. What is the difference between LinkedBlockingQueue and ArrayBlockingQueue?

Flag important question
Mark as complete

Thread-safe Collections

25. Describe and compare fail-fast and fail-safe iterators. Give examples.

Pro Content

26. What is a Concurrent Collection?

Pro Content

27. What is the difference between CopyOnWriteArrayList and ArrayList?

Pro Content

28. How do thread-safe collections achieve thread safety?

Pro Content

29. What are the trade-offs of using BlockingQueue in a multithreaded application?

Pro Content

Generics and Collections

30. What is the benefit of Generics in Collections Framework in java?

Pro Content

Sorting and Comparators

31. What is the difference between Comparable and Comparator? When would you use each?

Pro Content

32. How do you sort a Map by its keys or values?

Pro Content

33. What are the benefits of using the sort() method in List over Collections.sort()?

Pro Content

Performance and Memory

34. What Are the Time/Space Complexities of HashMap, ArrayList, and LinkedList?

Pro Content

35. How does HashMap achieve O(1) performance for insertions and lookups?

Pro Content

36. What is the memory overhead of a HashSet compared to a TreeSet?

Pro Content

37. How can you optimize memory usage for collections?

Pro Content

Advanced Topics

38. What is an IdentityHashMap, and how does it differ from a HashMap?

Pro Content

39. How do NavigableMap and NavigableSet differ from SortedMap and SortedSet?

Pro Content

40. How does EnumMap improve performance for maps with enum keys?

Pro Content