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.

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.

MediumTechnical
71 practiced

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?

HardSystem Design
79 practiced

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.

MediumTechnical
50 practiced

You observe sustained high CPU utilization in a Java backend process. Describe step-by-step how you would identify CPU hotspots and expensive code paths in production with minimal impact. Include tools (async-profiler, Java Flight Recorder, jstack sampling), how to interpret flame graphs, and strategies you would use to reduce CPU usage such as algorithmic improvements, caching, or moving work off the hot path.

MediumTechnical
56 practiced

Describe how you would instrument a Java Spring Boot REST endpoint to capture latency percentiles using Micrometer and export to Prometheus. Provide sample metric naming conventions and tag (label) choices, the Prometheus query to compute the 95th percentile over the last 5 minutes, and discuss pitfalls such as label cardinality and choosing histogram vs summary.

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.