OOP, JVM and backend craft
Java Interview Questions
Collections, concurrency, the JVM, Spring and the Java questions behind reliable backend services.
40 questions10 easy22 medium8 hard0/40 learned
01What is Java and what makes it platform independent?Easyjava · bytecode · platform independence02What is the difference between the JVM, JRE and JDK?Easyjvm · jdk · jre03What is the Java Memory Model?Hardjava memory model · happens-before · visibility04How does garbage collection work in the JVM?Hardgarbage collection · heap · gc tuning05What is the difference between primitives and wrapper classes?Easyprimitives · autoboxing · wrapper classes06Why is String immutable in Java?Mediumstring · immutability · string pool07What is the difference between StringBuilder and StringBuffer?Easystringbuilder · stringbuffer · mutability08What is the contract between equals and hashCode?Mediumequals · hashcode · collections09Give an overview of the Java collections framework.Easycollections · list · map10When would you use ArrayList versus LinkedList?Mediumarraylist · linkedlist · data structures11How does HashMap work internally?Hardhashmap · hashing · collisions12How does ConcurrentHashMap achieve thread safety?Hardconcurrenthashmap · concurrency · thread safety13What is the difference between Comparable and Comparator?Mediumcomparable · comparator · sorting14How do generics work in Java and what is type erasure?Mediumgenerics · type erasure · wildcards15How does exception handling work in Java?Easyexceptions · try-catch · error handling16What is the difference between checked and unchecked exceptions?Mediumchecked exceptions · unchecked exceptions · api design17How does try-with-resources work?Mediumtry-with-resources · autocloseable · resource management18What are the core object-oriented principles in Java?Easyoop · encapsulation · abstraction19When would you use an interface versus an abstract class?Mediuminterfaces · abstract classes · design20Why is composition often preferred over inheritance?Mediumcomposition · inheritance · design21What is polymorphism and how does Java implement it?Mediumpolymorphism · overriding · dynamic dispatch22How do you design an immutable class in Java?Mediumimmutability · defensive copying · records23How does the Java Streams API work?Mediumstreams · functional · collectors24What is Optional and when should you use it?Mediumoptional · null safety · api design25What is a lambda expression in Java?Easylambdas · functional programming · syntax26What is a functional interface and which ones does Java provide?Mediumfunctional interfaces · sam · java.util.function27What are the basics of concurrency in Java?Mediumthreads · race conditions · concurrency28How do thread pools work and how do you size them?Mediumthread pool · executorservice · virtual threads29How does CompletableFuture support asynchronous composition?Hardcompletablefuture · async · composition30How does synchronized compare with explicit locks?Hardsynchronized · reentrantlock · locking31What does volatile guarantee and what does it not?Mediumvolatile · visibility · happens-before32How do atomic classes work and when should you use them?Mediumatomics · cas · lock-free33How does class loading work in the JVM?Hardclassloading · classloader · jvm34What is Spring Boot and how does it simplify Spring applications?Easyspring boot · auto-configuration · starters35How does dependency injection work in Spring?Mediumdependency injection · spring · ioc36How do you build a REST API with Spring?Mediumrest · spring mvc · http37How do JPA and Hibernate work together?Hardjpa · hibernate · orm38How do transactions work in Spring?Mediumtransactions · spring · acid39How do you test Java and Spring applications?Mediumjunit · testing · mockito40What Java practices do you apply in production code?Easybest practices · clean code · maintainability
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Java mock interview and get scored feedback on depth, clarity and confidence.