This document summarizes the interview questions covered by the examples in this repository.
- Total Java Classes/Files: 493
Based on src/corejava/streams and src/corejava/streams/questions:
- How to use
flatMapto flatten a list of lists? - Difference between
map()andflatMap()? - How to group objects by a property using
Collectors.groupingBy? - How to find the maximum value in a grouped result?
- How to calculate average, min, and max using
IntStreamorCollectors? - How to filter duplicates from a list using Streams?
- How to sort a Map by keys or values using Streams?
- How to convert a List of objects into a Map?
Based on src/corejava/collections and src/corejava/collections/hashcodeequals:
- Difference between
HashMapandHashTable? - How does
HashSethandle duplicate objects? (Role ofhashCode()andequals()) - Difference between
ComparableandComparator? - How to sort a
HashMapby key? - When to use
TreeMapvsHashMap? - How to make a
HashMapthread-safe? - Performance difference between
ArrayListandLinkedList?
Based on src/corejava/exceptions and src/corejava/exceptions/questions:
- Can we have a
tryblock withoutcatch? (Usingfinallyor Try-with-resources) - What is the sequence of catch blocks for hierarchical exceptions?
- Difference between Checked and Unchecked exceptions?
- What happens if an exception is thrown in a constructor?
- Multi-catch block syntax and rules (Java 7+).
Based on src/corejava/language/encapsulation, src/corejava/oop/inheritance/questions, and src/corejava/language/keywords:
- Can we override a
finalmethod? - Difference between method overloading and overriding?
- How does
instanceofpattern matching work in later Java versions? - Can we override a
staticmethod? (Method Hiding) - Use of
superandthiskeywords in inheritance. - Abstract classes vs Interfaces (especially with Java 8/9+ default/static/private methods).
Based on src/corejava/concurrency/threads and src/corejava/concurrency:
- Difference between
wait()andsleep()? - How to create a thread using
RunnablevsThreadclass? - What is the
ExecutorServiceand how to use it? - Difference between
synchronized - What are Atomic variables (e.g.,
AtomicInteger) and why are they used?
Based on src/corejava/jdkfeatures/java8, src/corejava/jdkfeatures/java11, and src/corejava:
- What are Functional Interfaces and
@FunctionalInterfaceannotation? - Lambda expressions syntax and usage.
- New methods in
Stringclass (Java 11). - Pattern Matching for
instanceof. - Local Variable Type Inference (
var).
- Serialization and Deserialization in Java.
- Pass by value vs Pass by reference in Java (Java is strictly pass-by-value).
- String pool and String immutability.
- Use of
staticblocks and initializers.
- For a detailed mapping of every interview question to its corresponding source code file, please refer to DetailedInterviewQuestions.md.
- For a list of rephrased common interview questions, see RephrasedInterviewQuestions.md.