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.

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.

MediumTechnical
47 practiced

Implement a thread-safe token-bucket rate limiter in Java that supports per-user limits. Provide a class TokenBucketRateLimiter with a method boolean allowRequest(String userId). Requirements: thread-safe for concurrent requests, tokens refill at a rate tokensPerSecond with a max burst capacity, memory-bounded (evict state for inactive users), and reasonable performance for many users. You may provide code or pseudo-code (Java 8+).

HardSystem Design
54 practiced

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.

MediumTechnical
44 practiced

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.

EasyTechnical
41 practiced

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.

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.