Top 25 Java OOP Interview Questions for Experienced Developers
Top 25 Java OOP Interview Questions for Experienced Developers Work through these 15 questions out loud. Open any question for the full model answer, the trap to avoid, and the follow-up a panel usually asks.
Why does Context re-render every consumer, and how do you keep RBAC/theme from stalling the tree?
AuthProvider holds user with useMemo. Permission checks go through can(permission) from a hook that reads a stable access object. Theme is a separate provider. High-frequency...
Explain the difference between == and .equals() in Java.
For primitives, == compares values. For objects, == asks if two references point to the same instance. equals() compares content when overridden — String overrides it for...
What is dependency injection and why does Spring use it?
DI supplies collaborators from outside the class — typically via constructor. Problem solved: tight coupling to concrete classes, hard unit tests, scattered object...
@RestController vs @Controller?
@Controller is for traditional MVC — return "user/list" view name. @RestController adds @ResponseBody so return types become JSON/XML body — standard for REST APIs. Use...
What is the difference between Comparable and Comparator?
Comparable built into the type — Employee implements compareTo by id. Comparator external — sort by name or salary without changing Employee. Use...
Explain method overloading vs overriding.
Overload print(int) and print(String) in one class — compiler picks at compile time. Override toString in subclass — JVM calls subclass version via virtual method table....
How does Bean Validation work in Spring Boot 3?
DTO fields: @NotBlank, @Email, @Size. Controller: createUser(@Valid @RequestBody UserDto dto). Global @RestControllerAdvice maps MethodArgumentNotValidException to 400 + field...
What do Java Records provide and their limitations?
DTO: record UserResponse(String id, String name) {} — JSON mapping works. Service layer immutable value objects. Not for entities needing setters/lazy proxies yet. Combine with...
BeanFactoryPostProcessor vs BeanPostProcessor — explain both.
BFPP: replace ${placeholder} in definitions via PropertySourcesPlaceholderConfigurer. BPP: @Autowired injection, @PostConstruct detection, AOP proxy wrapping. Custom BPP can...
What is the difference between JPA and Hibernate?
JPA is the API contract; Hibernate is the engine under Spring Boot by default. You write @Entity per JPA spec; Hibernate handles SQL generation. Spring Data JpaRepository adds...
Explain sealed classes and their purpose in Java 17+.
sealed interface Shape permits Circle, Rectangle limits who implements Shape. Compiler verifies switch (Shape s) covers all cases — no default needed. Use for domain variants...
What is the Java Platform Module System (JPMS) and who needs it?
Use modules when building custom JDK images or publishing strict API boundaries. Typical microservice: no module-info — Spring Boot repackages classpath. Watch for illegal...
Explain @ConfigurationProperties vs @Value.
@ConfigurationProperties(prefix = "app.payment") record PaymentProps(int timeout, String apiUrl) {} — validated, testable, grouped. Use @Value only for single feature flags....
When use @Query native SQL vs JPQL in Spring Data JPA?
JPQL for standard entity fetches and portable logic. Native for PostgreSQL-specific jsonb queries, recursive CTEs, or performance-tuned index hints after EXPLAIN. Interface...
What is Metaspace and how do class loading issues cause memory leaks?
Production set MaxMetaspaceSize 256m with monitoring. Investigate Metaspace OOM: heap dump + classloader histogram. Avoid generating unlimited dynamic proxies. OSGi/script...
Java OOP Interview Questions and Answers · Top 50 Java OOP Interview Questions and Answers (2026 Edition) · Top 40 Java OOP Interview Questions | Must-Prepare before interview. · Java OOP Interview Questions Every Fresher Must Know
All interview question lists · Interview guides · Home · Support the platform