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
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.

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
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.

HardTechnical
54 practiced

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.

EasyTechnical
52 practiced

Explain Java memory model basics relevant to backend engineers: heap vs stack, where objects are allocated, what young and old generations are, what triggers a Full GC, and simple coding patterns that commonly increase GC pressure in web services.

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.