Huru
Technical Interviews

Java 8 Interview Questions and Answers (2026)

Java 8 interview questions with short answers and code: lambdas, functional interfaces, method references, default methods, the Stream API (map, filter, reduce, collect, groupingBy), intermediate vs terminal operations, parallel streams, Optional, the java.time API, CompletableFuture, plus why Java 8 still comes up in 2026.

By Amine Boukioud Updated 4 min read
The Huru mascot holding a laptop and pointing at a transparent pipe where colored blocks pass through filter and transform rings into a sorted stack, with a coffee cup nearby

The short answer: Java 8 questions are still a staple of Java interviews because its features, lambdas, functional interfaces, default methods, the Stream API, Optional and the java.time API, are how modern Java is written, and Java 8 itself is still supported: Oracle lists extended support for Java SE 8 until December 2030. Expect to explain each feature, write short stream pipelines (filter, map, group, collect), and discuss trade-offs such as when parallel streams help. Below are the common questions with short answers and code.

Why Java 8 still comes up

Java 8 was released in March 2014. Oracle’s support roadmap lists Java SE 8 as a long-term support release with extended support until December 2030, alongside later LTS releases (11, 17, 21 and 25). Many production systems still run it, and its features are the foundation of everything since, so interviewers use it to check modern Java fluency.

Lambdas and functional interfaces

“What is a lambda expression?”

Oracle describes lambdas as letting you “treat functionality as a method argument, or code as data.” A lambda is a concise implementation of a functional interface:

Comparator<String> byLength = (a, b) -> Integer.compare(a.length(), b.length());

“What is a functional interface?”

An interface with exactly one abstract method, such as Runnable, Comparator, or those in java.util.function: Predicate<T> (returns boolean), Function<T,R> (transforms), Consumer<T> (accepts, returns nothing), and Supplier<T> (produces a value). @FunctionalInterface makes the compiler enforce it.

“What are method references?”

Shorthand for lambdas that just call an existing method: String::toUpperCase, System.out::println, ArrayList::new.

“What can a lambda capture?”

Local variables that are final or effectively final, plus fields. That’s why you can’t increment a local counter inside a lambda.

Default and static methods in interfaces

“Why were default methods added?”

Oracle explains that “default methods enable new functionality to be added to the interfaces of libraries and ensure binary compatibility with code written for older versions.” That’s how forEach and stream() were added to existing collection interfaces.

“What happens if a class inherits two default methods with the same signature?”

It won’t compile until the class overrides the method; it can call a specific one with InterfaceName.super.method().

The Stream API

“What is a stream?”

A sequence of elements supporting functional-style operations, from the java.util.stream package, integrated with collections “which enables bulk operations on collections, such as sequential or parallel map-reduce transformations,” as Oracle puts it. A stream doesn’t store data and can be consumed only once.

“What’s the difference between intermediate and terminal operations?”

Intermediate operations (filter, map, sorted, distinct) return a new stream and are lazy; nothing runs until a terminal operation (collect, forEach, reduce, count, findFirst) is called.

“Group employees by department and count them.”

Map<String, Long> countByDept = employees.stream()
    .collect(Collectors.groupingBy(Employee::getDepartment, Collectors.counting()));

“Find the names of the three highest-paid employees.”

List<String> top3 = employees.stream()
    .sorted(Comparator.comparingDouble(Employee::getSalary).reversed())
    .limit(3)
    .map(Employee::getName)
    .collect(Collectors.toList());

“What’s the difference between map and flatMap?”

map transforms each element into one element; flatMap transforms each element into a stream and flattens the results, for example turning a list of orders into a stream of all their items.

“When should you use parallel streams?”

For large, CPU-bound workloads with independent, stateless operations and data structures that split well (arrays, ArrayList). Avoid them for small collections, I/O-bound work, or operations with shared mutable state; they use the common fork-join pool, so measure before and after.

Optional

“What is Optional for, and how should you use it?”

A container that may or may not hold a value, mainly as a return type to make “no result” explicit. Prefer map, orElse, orElseGet and orElseThrow over calling get() without checking, and don’t use Optional for fields or method parameters.

String city = findUser(id)
    .map(User::getAddress)
    .map(Address::getCity)
    .orElse("Unknown");

Date and time

“What problems did java.time solve?”

The old Date and Calendar classes were mutable and not thread-safe, with confusing APIs. The java.time package, which Oracle describes as “a comprehensive date-time model,” has immutable types: LocalDate, LocalDateTime, ZonedDateTime, Instant, Duration and Period, plus a thread-safe DateTimeFormatter.

Concurrency

“What is CompletableFuture?”

A future you can compose without blocking: chain steps with thenApply and thenCompose, combine with thenCombine or allOf, and handle errors with exceptionally or handle.

Other Java 8 changes worth knowing

  • HashMap collisions: buckets with many entries switch from linked lists to balanced trees, improving worst-case lookups.
  • PermGen was replaced by Metaspace for class metadata.
  • Nashorn replaced the Rhino JavaScript engine (it was later removed in Java 15).

How to answer well

Explain the “why,” not only the syntax: readability, immutability, laziness, and when not to use a feature. Write code out loud, and mention what changed in later versions if you know it (for example var, records and Stream.toList()).

See also our Python interview questions for junior developers and system design interview guide.

Frequently asked questions

What are the main features of Java 8?
Lambda expressions, functional interfaces, method references, default and static methods in interfaces, the Stream API, Optional, the java.time date-time API, CompletableFuture, and the Nashorn JavaScript engine.
What is the difference between intermediate and terminal stream operations?
Intermediate operations such as filter, map and sorted return a new stream and are lazy; terminal operations such as collect, forEach and reduce trigger processing and produce a result.
What is a functional interface in Java?
An interface with exactly one abstract method, such as Runnable, Comparator, Predicate or Function. Lambdas and method references implement functional interfaces.
Is Java 8 still used in 2026?
Yes. Oracle lists extended support for Java SE 8 until December 2030, and many production systems still run it, though newer LTS releases (11, 17, 21, 25) are common for new projects.
When should I use parallel streams?
For large, CPU-bound workloads with independent, stateless operations on data that splits well. Avoid them for small collections, I/O-bound tasks or shared mutable state, and measure performance.

Sources

Practice this with Huru AI

Turn what you just read into a rehearsal. Unlimited AI mock interviews with instant, specific feedback.

Amine Boukioud

Amine Boukioud is a co-founder of Beatview, Inc., the company behind Huru, and Head of Growth at Huru. He writes and reviews Huru’s interview guides; each one starts from primary sources such as employers’ own careers pages, official data and research, and follows Huru’s editorial policy.

Published · Updated

How this article was made: researched and drafted with AI assistance, then written, fact-checked and signed by Amine Boukioud on October 1, 2026. Sources are linked where they are used. How we work: editorial policy.