InterviewStack.io LogoInterviewStack.io

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.

MediumTechnical
43 practiced

Design a caching strategy to reduce database load for user profile reads where updates must be visible immediately to subsequent reads (strong consistency). The service is Java/Spring Boot and uses a relational DB. Propose an architecture including cache type (distributed vs local), invalidation/eviction strategy, and how to implement atomic invalidation with database updates, considering multi-instance coherence.

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.

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?

EasyTechnical
51 practiced

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.

HardTechnical
52 practiced

After a production deploy, the 99th percentile latency for a Java service increased dramatically. Traces show a single DB query changed from 10ms to 1.5s and is performing a sequential scan. Outline an incident response plan: immediate mitigations to reduce user impact, steps to identify the root cause (code changes, query plan, statistic changes), how to perform safe rollback or hotfix, and how to write a postmortem with actionable items to prevent recurrence.

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.