Skip to main content

Java Interview Preparation Roadmap


1. Core Java

TopicSubtopicsExample Questions / Practice
OOP ConceptsInheritance, Polymorphism (compile/runtime), Abstraction, Encapsulation, InterfacesExplain runtime vs compile-time polymorphism.
Design a shape class hierarchy with method overriding.
Java Basicsmain method, packages, access modifiers- Difference between public, private, protected, default.
- Explain static keyword and its use cases.
Data Types & VariablesPrimitive vs Wrapper, autoboxing/unboxing- Difference between int and Integer.
- What happens during autoboxing?
StringsString, StringBuilder, StringBuffer, immutability- Why String is immutable?
- Compare StringBuilder vs StringBuffer.
Collections FrameworkList, Set, Map, Queue, implementations, differences- Difference between ArrayList and LinkedList.
- Implement LRU cache using LinkedHashMap.
GenericsBounded types, wildcards, type erasure- Difference between ? extends T and ? super T.
- Why Java uses type erasure?
Exception HandlingChecked vs unchecked, throw vs throws, custom exceptions- Write a custom exception.
- Explain try-with-resources.
Java Memory ModelStack vs Heap, GC, memory leaks, references- Explain strong, weak, soft, phantom references.
- What is a memory leak in Java?

2. Java 8+ Features

TopicSubtopicsExample Questions / Practice
Functional InterfacesPredicate, Function, Consumer, Supplier- Use Predicate to filter a list of strings starting with “A”.
LambdasSyntax, capturing variables, method references- Convert an anonymous class into a lambda.
- Explain this reference inside a lambda.
Streams APIMap, filter, reduce, collect, parallel streams- Count distinct words in a list.
- Group employees by department using streams.
OptionalAvoiding NPE, ifPresent, orElse- How to avoid NullPointerException with Optional?
Date/Time APILocalDate, LocalTime, LocalDateTime, formatting- Calculate days between two dates using java.time.

3. Multithreading & Concurrency

TopicSubtopicsExample Questions / Practice
ThreadsThread vs Runnable vs Callable, Future- Implement a multi-threaded task using Callable and Future.
Synchronizationsynchronized, Locks, Deadlock- Write a deadlock example and solve it.
Executor FrameworkExecutorService, ScheduledExecutorService- Schedule a task to run every 5 seconds.
Concurrent CollectionsConcurrentHashMap, CopyOnWriteArrayList- Difference between HashMap and ConcurrentHashMap.
Java Memory Visibilityvolatile, happens-before- Explain volatile with an example.
ForkJoinPoolDivide & conquer parallelism- Implement parallel sum of an integer array.

4. Advanced Java / JVM

TopicSubtopicsExample Questions / Practice
JVM InternalsClass loading, bytecode, JIT- Explain JVM memory areas.
- What is classloader hierarchy?
Garbage CollectionSerial, Parallel, CMS, G1- How does G1 GC work?
- Explain memory leak examples.
Annotations & ReflectionCustom annotations, reflection API- Create a custom annotation and process it using reflection.
SerializationSerializable, Externalizable, transient- Explain difference between Serializable and Externalizable.
Java Modulesmodule-info.java, exports, requires- Explain module system in Java 9+.

5. Design Patterns & Best Practices

TopicSubtopicsExample Questions / Practice
Design PatternsSingleton, Factory, Builder, Observer, Strategy- Implement a thread-safe singleton.
- Use Builder pattern to create an object.
SOLID PrinciplesSRP, OCP, LSP, ISP, DIP- Refactor a class violating SRP.
Effective Java Practicesequals()/hashCode(), immutability- Implement proper equals() and hashCode().
- Make a class immutable.

6. Spring & Hibernate (if applicable)

TopicSubtopicsExample Questions / Practice
Spring CoreIoC, DI, Bean lifecycle- Explain constructor vs setter injection.
Spring BootAuto-configuration, profiles, starters- How does Spring Boot simplify app setup?
Spring MVCControllers, REST API- Write a REST API to get employee details.
Spring SecurityAuthentication, JWT, OAuth2- Implement basic JWT authentication.
JPA & HibernateEntity lifecycle, caching, relationships- Map a OneToMany and ManyToOne relationship.
- Difference between lazy vs eager fetch.

7. Common Coding/Design Questions

  • Implement LRU Cache using LinkedHashMap.
  • Producer-Consumer problem with threads.
  • Deadlock demonstration and resolution.
  • Custom comparator for sorting.
  • Stream-based grouping/filtering/counting problems.
  • Thread-safe singleton & object pool implementation.

💡 Preparation Tips:

  1. Start with Core Java → practice coding + conceptual questions.
  2. Move to Java 8 features + Collections + OOP.
  3. Dive into Multithreading + Concurrency.
  4. Cover JVM internals + Garbage Collection + Serialization.
  5. Finally, Spring/Hibernate + Design Patterns + Advanced coding.