Top 10 Java Streams Interview Questions Every Fresher Should Know

Top 10 Java Streams Interview Questions Every Fresher Should Know Work through these 10 questions out loud. Open any question for the full model answer, the trap to avoid, and the follow-up a panel usually asks.

  1. A REST API is slow only in production, not locally. How do you debug it?

    Enable Micrometer timers and Hibernate statistics or datasource-proxy in staging with prod-like data. Check Hikari `connections-active`, JVM GC pauses, and Feign/RestClient...

    Full answer

  2. One API intermittently times out, no errors in logs. How do you debug?

    No app log may mean thread blocked waiting on external IO. Enable Feign/logger + trace. Check LB/proxy timeouts vs client timeouts. ```yaml feign: client: config: default:...

    Full answer

  3. What are hidden classes in JDK 15, and which runtime frameworks rely on them?

    I do not write hidden classes in business code. I know JDK 15+ lambdas and several proxy libraries use them so generated bytecode unloads cleanly. If a heap dump shows...

    Full answer

  4. What is the difference between Comparable and Comparator?

    Comparable built into the type — Employee implements compareTo by id. Comparator external — sort by name or salary without changing Employee. Use...

    Full answer

  5. Stream.toList() vs Collectors.toList() in modern Java?

    Public API return users.stream().filter(...).toList() — immutable contract. Internal processing needing mutation: collect(Collectors.toList()). Java 21+ sequenced collections...

    Full answer

  6. Explain garbage collection basics in the JVM.

    New objects allocate in Eden; minor GC copies survivors to survivor spaces, then old gen. When old gen fills, major/full GC runs — longer pauses. Tune -Xmx, choose G1 for...

    Full answer

  7. How does Stream API parallel stream work?

    parallelStream() splits work across common pool threads. Good for CPU-heavy map on large in-memory collections. Bad for small lists, IO inside stream, or ordered stateful...

    Full answer

  8. What is ForkJoinPool common pool starvation and how do you avoid it?

    Never block on common pool — no DB/HTTP in parallelStream without custom pool. Use Executors.newFixedThreadPool for blocking batch jobs. CompletableFuture.supplyAsync(task,...

    Full answer

  9. How do Spring Boot Actuator health probes work with Kubernetes?

    Enable probes, configure K8s readinessProbe on /actuator/health/readiness, liveness on /actuator/health/liveness. Custom HealthIndicator for critical deps on readiness group...

    Full answer

  10. How does Micrometer Tracing replace Spring Cloud Sleuth?

    Dependencies: micrometer-tracing-bridge-otel, opentelemetry-exporter-otlp. Traces propagate Authorization-safe headers across RestClient/WebClient calls. Correlate logs with...

    Full answer

Java Streams Interview Questions and Answers · Top 50 Java Streams Interview Questions and Answers (2026 Edition) · Top 40 Java Streams Interview Questions | Must-Prepare before interview. · Java Streams Interview Questions Every Fresher Must Know

All interview question lists · Interview guides · Home · Support the platform