Java 8 - Interview Gold (5+ year experienced)
LAMBDA & FUNCTIONAL INTERFACE
1. What is a functional interface?
2. Is @FunctionalInterface mandatory?
3. Can a functional interface have default methods?
4. Why were lambdas introduced?
5. Lambda vs anonymous class
STREAM API (MOST IMPORTANT)
6. Stream vs Collection
7. Intermediate vs Terminal operations
8. map() vs flatMap()
9. filter() vs map()
10. findFirst() vs findAny()
11. limit() vs skip()
12. peek() – real use case
13. forEach vs forEachOrdered
14. reduce() explained with example
15. collect() – internal working
16. groupingBy() vs partitioningBy()
17. How to remove duplicates using Stream?
18. Parallel stream – when NOT to use?
19. Stream performance vs for-loop
20. Can we reuse a stream?
21. Lazy evaluation in streams
OPTIONAL (Tricky area)
22. Why Optional was introduced?
23. orElse vs orElseGet
24. Can Optional be null?
25. Is Optional Serializable?
26. Best practices for using Optional in APIs
DATE & TIME API
27. Date vs LocalDate
28. LocalDate vs LocalDateTime
29. ZonedDateTime – real use case
30. How to convert String to LocalDate?
31. Thread safety of Java 8 Date-Time API
DEFAULT & STATIC METHODS (Interfaces)
32. Why default methods were introduced?
33. Multiple interface default method conflict – how resolved?
34. Can a default method be overridden?
35. Static methods in interface – use case?
MOST COMMON SCENARIO QUESTIONS
36. You need a thread-safe cache – what will you use?
37. You need a sorted + fast lookup map – which one?
38. Handling large data with streams – approach?
39. How to design an immutable class?
40. How to make a singleton thread-safe?
41. How to write equals() and hashCode() correctly?
42. How do you debug a production issue?
43. How do you improve performance of existing code?
follow for more content :
