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.

HardSystem Design
47 practiced

Design a high-throughput order processing backend implemented in Java to accept 5,000 orders per second peak with sub-200ms write latency requirements, ensure strong consistency for inventory reservations and payments, and provide APIs for order status queries. Describe overall architecture, how you would partition and scale the relational datastore (sharding strategies, read replicas), where to use synchronous vs asynchronous processing, idempotency handling, and how to ensure and measure availability and throughput. Discuss trade-offs and failure modes.

EasyTechnical
40 practiced

In Java 8+, describe and (optionally) write a short JDBC code example that executes a simple SELECT and demonstrates correct resource management with try-with-resources. Show creating the Connection, PreparedStatement, executing the query, iterating the ResultSet, and handling SQLExceptions. Explain why try-with-resources prevents resource leaks compared to manual finally blocks.

MediumTechnical
43 practiced

Design a caching strategy to reduce database load for user profile reads where updates must be visible immediately to subsequent reads (strong consistency). The service is Java/Spring Boot and uses a relational DB. Propose an architecture including cache type (distributed vs local), invalidation/eviction strategy, and how to implement atomic invalidation with database updates, considering multi-instance coherence.

HardTechnical
39 practiced

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.

EasyTechnical
49 practiced

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.

Unlock Full Question Bank

Get access to all 33 Java Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.