Published:
Last updated:

Java Collections

Authors
Time yourself:
Your progress:

00:30:00

0%

Filter by difficulty

40 of 40 questions shown

List

1. Why are collections preferred over arrays in Java?

Mid-level
Flag important question
Mark as complete

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

Mid-level
Flag important question
Mark as complete

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

Mid-level
Flag important question
Mark as complete

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

Mid-level
Flag important question
Mark as complete

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

Mid-level
Flag important question
Mark as complete

Set

Free preview complete

You’ve reached the end of the free preview

Get every remaining question and complete answer, plus progress tracking across the full Interview Question Library.

  • 35 more questions and complete answers in this topic
  • Full access to every interview topic
  • Progress tracking and question flags
  • New questions and improvements during your subscription

Full access from

$12/month

No long-term commitment. Cancel whenever you want.

6. How do HashMap and HashSet Work Internally?

Mid-levelPaid Question

7. How does a HashSet ensure uniqueness of elements?

Mid-levelPaid Question

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

Mid-levelPaid Question

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

Mid-levelPaid Question

10. How is iteration order maintained in LinkedHashSet?

Mid-levelPaid Question

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

Mid-levelPaid Question

12. How does TreeSet maintain its sorting order?

Mid-levelPaid Question

Map

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

Mid-levelPaid Question

14. How does LinkedHashMap maintain insertion order?

Mid-levelPaid Question

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

JuniorPaid Question

16. What is the difference between HashMap and Hashtable?

Mid-levelPaid Question

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

Mid-levelPaid Question

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

Mid-levelPaid Question

19. How does ConcurrentHashMap achieve thread safety?

Mid-levelPaid Question

Queue and Deque

20. What is the difference between Queue and Deque?

Mid-levelPaid Question

21. How does a PriorityQueue determine element order?

Mid-levelPaid Question

22. What are the use cases for ArrayDeque?

Mid-levelPaid Question

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

Mid-levelPaid Question

24. What is the difference between LinkedBlockingQueue and ArrayBlockingQueue?

Mid-levelPaid Question

Thread-safe Collections

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

Mid-levelPaid Question

26. What is a Concurrent Collection?

JuniorPaid Question

27. What is the difference between CopyOnWriteArrayList and ArrayList?

Mid-levelPaid Question

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

Mid-levelPaid Question

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

Mid-levelPaid Question

Generics and Collections

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

JuniorPaid Question

Sorting and Comparators

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

Mid-levelPaid Question

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

Mid-levelPaid Question

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

JuniorPaid Question

Performance and Memory

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

Mid-levelPaid Question

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

Mid-levelPaid Question

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

Mid-levelPaid Question

37. How can you optimize memory usage for collections?

SeniorPaid Question

Advanced Topics

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

Mid-levelPaid Question

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

Mid-levelPaid Question

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

Mid-levelPaid Question