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.
Explain the following transaction anomalies: dirty reads, non-repeatable reads, phantom reads, lost updates, and write skew. For a banking transfer service that concurrently updates account balances, recommend an isolation strategy and application-level patterns (SELECT FOR UPDATE, optimistic locking with version columns, or serializable isolation) to prevent lost updates while maintaining acceptable throughput. Discuss trade-offs and behavior differences between Postgres and MySQL.
Explain dependency injection in Java backend applications and compare constructor injection, setter injection, and field injection in Spring. Describe advantages and disadvantages of each approach, testability implications, and common pitfalls (for example circular dependencies). Provide a short Java (Spring Boot) example showing constructor injection for a Service that depends on a UserRepository.
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.
Explain the difference between synchronized, volatile, and java.util.concurrent.atomic.AtomicInteger in Java. For each, describe the guarantees provided about memory visibility and atomicity, and give an example scenario where it is the appropriate choice.
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.