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.

HardTechnical
38 practiced

Design a custom JDBC connection pool for Java applications. Describe the key components and algorithms: connection acquisition and release, max pool size, wait time and backpressure behavior, validation of connections, eviction of stale or broken connections, leak detection, and metrics to expose. Explain how you'd implement leak detection and how to avoid thundering herd when the pool is exhausted.

EasyTechnical
52 practiced

Describe the core observability signals you would add to a Java microservice to support production debugging and performance monitoring: metrics, structured logs, and distributed traces. For each signal give three concrete examples (metric name, log field, or span annotation), list Java libraries you'd use, and explain strategies to avoid high-cardinality metrics.

MediumTechnical
38 practiced

Compare OFFSET/LIMIT pagination with keyset (cursor) pagination. For a posts table with columns id (PK) and created_at, write an example SQL query using keyset pagination to fetch the next page given the last seen cursor values. Describe how to implement keyset pagination in Java (Spring Data or manual SQL) and trade-offs when sorting by multiple columns.

HardTechnical
41 practiced

Implement or outline a thread-safe LRU cache in Java that supports O(1) get and put operations, an optional TTL per entry, and an eviction callback. Provide the public API and describe an implementation using ConcurrentHashMap and a concurrency-friendly eviction structure, or explain how to use existing libraries (e.g., Caffeine) and why they are preferable. Discuss correctness under concurrency and tests you'd write to validate behavior.

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.