Back to blog Java Interview

50 mostly-asked Java 8 interview questions

32 min readJava Interview

Java 8 Core Concepts (Fundamentals)

1. What are the main features introduced in Java 8?

2. What is a Lambda Expression? Explain with syntax and example.

3. What is a Functional Interface? Give examples.

4. What is the Stream API and why is it used?

5. What is Optional and how does it help avoid NullPointerException?

6. What are default methods in interfaces? Why were they introduced?

7. What are static methods in interfaces?

8. What is a method reference? What are its types?

9. Difference between Collection and Stream.

10. What is type inference in Java 8?

11. What are intermediate and terminal operations in Streams?

12. What is a Spliterator?

13. What is Nashorn JavaScript engine?

14. What is jjs tool in Java 8?

15. What are the main functional interfaces in java.util.function?

Stream API & Coding-Based Questions

1. How do you remove duplicates from a list using Streams?

2. How do you separate even and odd numbers using Java 8 Streams?

3. How do you count frequency of characters in a string using Streams?

4. How do you sort a list in reverse order using Streams?

5. How do you merge two lists and sort them using Streams?

6. How do you filter numbers divisible by 5 using Streams?

7. How do you convert a list of strings to uppercase using Streams?

8. How do you find maximum and minimum values using Streams?

9. How do you group objects by a field using Collectors.groupingBy()?

10. How do you convert a list into a map using Collectors.toMap()?

11. How do you join a list of strings using Collectors.joining()?

12. How do you find the first non-repeated character in a string using Java 8?

13. How do you check if a string is palindrome using Java 8?

14. How do you count word occurrences in a sentence using Streams?

15. How do you sort a map by values using Java 8?

Functional Interfaces & Lambda Expressions

1. What is the difference between Predicate, Function, Consumer, and Supplier?

2. What is BiFunction and BinaryOperator?

3. Can we create our own functional interface? How?

4. What is the difference between lambda expression and anonymous class?

5. What are effectively final variables in lambda expressions?

6. Can lambda expressions throw checked exceptions?

7. What is a constructor reference?

8. How do method references improve readability?

Date & Time API (java.time)

1. What problems existed with old Date and Calendar API?

2. What is LocalDate, LocalTime, and LocalDateTime?

3. How do you get current date and time in Java 8?

4. How do you format a date using DateTimeFormatter?

5. How do you calculate difference between two dates in Java 8?

6. How do you convert old Date to LocalDate?

Advanced / Experience-Level Questions

1. What is parallel stream? When should you use it?

2. Difference between sequential stream and parallel stream.

3. What is lazy evaluation in Streams?

4. What is short-circuiting operation in Streams?

5. What are side effects in Streams and how to avoid them?

6. What is CompletableFuture and how is it used in Java 8?

InterviewExpert.org

Writing about interviews, stacks, and getting hired.

Leave a comment