Java Programming Questions
The Java language and platform: type system, collections framework, generics, exceptions, the memory and JVM model, and idiomatic object-oriented Java. Covers writing correct Java and reasoning about its runtime and language semantics. A staple server-side and test-automation language surface.
Explain common @Transactional propagation behaviors in Spring (REQUIRED, REQUIRES_NEW, MANDATORY) and recommend which propagation to use for a funds transfer service that must debit one account and credit another atomically. Which database isolation level would you choose to avoid lost updates, and how would you implement optimistic or pessimistic locking in JPA for accounts?
Explain the difference between a primary key, a unique constraint/index, and a foreign key in a relational database. For each, give an example use case and discuss performance implications such as index usage for lookups and insert/update overhead. Also mention how each concept maps to JPA/Hibernate annotations.
A heap dump shows a large retained set attributed to org.example.cache.Cache$Node objects. Describe a methodical approach to identify the root cause, reproduce the leak locally, and remediate. Include tools to use (jmap, jcmd, Eclipse MAT), what to inspect in heap analyzers (GC roots, reference chains), common leak patterns (static collections, ThreadLocal, listener registrations), and tests or CI checks to prevent regressions.
Design a read-optimized, denormalized product catalog for a storefront API that must return product info, price, and inventory availability with low latency. Inventory updates are frequent. Explain denormalization approaches (duplicating columns, update streams, materialized views), how to propagate changes reliably (CDC, message queue with ordering), how to bound staleness, and how to handle conflicts or reconciliation when denormalized copies diverge.
In Java (Spring Boot) implement or describe a GET /users endpoint that supports query parameters page and size and returns a JSON list of users. The endpoint must also set a response header X-Total-Count with the total number of users matching criteria. Describe the controller method signature, service and repository interactions (you may reference Spring Data Pageable or a manual implementation), and how you would test correctness and edge cases.
Unlock Full Question Bank
Get access to all 33 Java Programming interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.