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.
Design a near-real-time analytics pipeline for dashboarding that must report metrics within 5 seconds of events without impacting the OLTP database. Consider using Change Data Capture (CDC), Kafka, stream processing (Flink or Kafka Streams), and a read-optimized store (ClickHouse, ClickHouse or ElasticSearch). Describe schema/aggregation choices, consistency and ordering concerns, backfill strategies, fault-tolerance, and how to measure pipeline lag and correctness.
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.
How would you structure tests for a Java DAO/Repository layer? Explain when to use unit tests, integration tests with an embedded or test database, and contract or migration tests. Name frameworks and tooling you would use (e.g., JUnit, Mockito, Testcontainers) and give examples of what each test type should assert.
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.
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.
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.