Collections and Streams Interview Questions for Java Full Stack with React
25 Collections and Streams questions with answers for java full stack with react roles — 7 easy, 14 medium, 4 hard.
About Collections and Streams
The Collections framework and the Streams API are used in almost every Java service. This topic covers List, Set and Map implementations, HashMap internals, equals and hashCode, concurrent collections, Comparator chains, lambdas, Optional and stream operations like groupingBy and flatMap. Expect both concept questions and live coding problems such as finding duplicates or the second highest salary.
When would you use ArrayList over LinkedList?
Show answer
What is the difference between Comparable and Comparator?
Show answer
What is a functional interface and how do lambdas relate to it?
Show answer
Find duplicate elements in a list of integers.
Show answer
You need to store unique usernames and always display them in alphabetical order. Which collection do you pick?
Show answer
How do you keep yourself updated with new Java versions and features?
Show answer
How does HashMap work internally?
Show answer
What is the contract between equals() and hashCode()?
Show answer
Compare HashMap, Hashtable and ConcurrentHashMap.
Show answer
What are fail-fast and fail-safe iterators?
Show answer
What are intermediate and terminal operations in Java Streams?
Show answer
Explain the difference between map and flatMap in streams.
Show answer
Using streams, group employees by department and count them.
Show answer
Find the second highest salary from a list of employees using streams.
Show answer
Sort a list of products by category, then by price descending, then by name.
Show answer
Count the frequency of each word in a sentence.
Show answer
You get ConcurrentModificationException while removing items from a list inside a for-each loop. How do you fix it?
Show answer
You are loading about five lakh records into an ArrayList and a HashMap and memory spikes during loading. What can you do?
Show answer
What are the correct and incorrect ways to use Optional?
Show answer
Describe a time you disagreed with a teammate during a code review.
Show answer
When should you use parallel streams and when should you avoid them?
Show answer
Implement a simple LRU cache in Java.
Show answer
An object put into a HashMap cannot be found later even though it looks equal. What could be wrong?
Show answer
A teammate replaced a simple for loop in a performance-critical path with a long stream pipeline. Is this a concern?
Show answer
Frequently asked questions
How important is Collections and Streams in Java Full Stack with React interviews?
The Collections framework and the Streams API are used in almost every Java service. This topic covers List, Set and Map implementations, HashMap internals, equals and hashCode, concurrent collections, Comparator chains, lambdas, Optional and stream operations like groupingBy and flatMap. Expect both concept questions and live coding problems such as finding duplicates or the second highest salary.
How should I use the Collections and Streams sheet?
Go top to bottom — easy to hard. Answer before opening each answer, tick what you solved and save misses to Last-Minute Revision.