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 strategy for applying schema changes to a production relational database used by Java backend services with zero or minimal downtime. Include steps for additive changes, backfilling computed fields, running online backfills, rolling out application code changes, and safe rollback. Mention tools you might use such as Flyway, Liquibase, gh-ost, or pt-online-schema-change.
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.
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.
A search API performs a JOIN between products and inventory tables and the call now takes roughly 2 seconds, blocking user requests. Describe a structured approach to diagnose why the join is slow: which metrics to look at (I/O, locks, CPU), how to get and interpret query plans, what to check in the database (indexes, stats, vacuuming), and concrete fixes such as indexing, denormalization, materialized views, or moving to a read-optimized store.
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.
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.