Java Developer Technical Questions Interview Questions
10 curated questions with evaluation guidance for hiring managers.
Explain how garbage collection works in Java. What are the different GC algorithms and when would you choose each?
Should explain young/old generation, mark-sweep-compact, G1GC, ZGC, and how to choose based on heap size, latency requirements, and throughput goals. Look for practical tuning experience.
How does the synchronized keyword work in Java? What alternatives exist for concurrent programming?
Should explain intrinsic locks, monitor pattern, and limitations. Should mention ReentrantLock, ReadWriteLock, ConcurrentHashMap, and the java.util.concurrent package. Look for modern concurrency approaches.
Explain how Spring Boot auto-configuration works. How would you customize or disable it?
Should discuss @EnableAutoConfiguration, @Conditional annotations, spring.factories, and excluding configurations. Look for understanding of the magic behind Spring Boot's convention-over-configuration.
What are Java streams and how do they differ from collections? When would you use parallel streams?
Should explain lazy evaluation, functional operations, pipeline structure, and stateless operations. Look for awareness that parallel streams can hurt performance with small datasets or shared resources.
Describe the differences between HashMap, TreeMap, and LinkedHashMap. What are their internal implementations?
Should explain hashing vs. red-black tree vs. doubly-linked list, ordering guarantees, and time complexity. Since Java 8, should mention treeification of HashMap buckets with many collisions.
How do you handle exceptions in a Spring Boot REST API? What is your approach to error responses?
Should mention @ControllerAdvice, @ExceptionHandler, ProblemDetail (RFC 7807), custom exception hierarchies, and logging strategies. Look for consistent error handling patterns.
Explain dependency injection in Spring. Compare constructor injection vs. field injection.
Should discuss Inversion of Control, bean lifecycle, and why constructor injection is preferred (immutability, testability, NPE prevention). Look for practical design philosophy.
How do you ensure thread safety in a Java application? Give examples from your experience.
Should discuss immutability, atomic classes, synchronization, concurrent collections, and thread-local variables. Look for ability to identify race conditions and choose appropriate solutions.
What are Java records and sealed classes? How do they improve your code?
Should explain records for immutable data carriers (reducing boilerplate), sealed classes for controlled inheritance hierarchies. Look for practical usage in domain modeling and pattern matching.
How do you test a Spring Boot application? What testing strategies do you use?
Should discuss unit tests (JUnit, Mockito), integration tests (@SpringBootTest, TestContainers), slicing (@WebMvcTest, @DataJpaTest), and test pyramid philosophy. Look for balanced testing approach.
Want AI-generated interview questions tailored to your specific job description? Workro analyses your JD and generates behavioural and technical questions calibrated for the role, seniority level, and required skills — in seconds.
Try free