A tricky question might present:
Optional<String> opt = Optional.ofNullable(null);
System.out.println(opt.get());
Answer: Throws NoSuchElementException because ofNullable(null) returns Optional.empty(), and calling get() on empty throws. The trap is thinking ofNullable magically avoids the exception—it only avoids NullPointerException during creation. ikm java 8 test updated
You should be able to rewrite any anonymous inner class as a lambda, and any simple lambda as a method reference. Example: What changed
(String s) -> s.length() → String::length and ConcurrentHashMap atomic methods.
Also, know the four functional interfaces well: Predicate<T>, Function<T,R>, Supplier<T>, Consumer<T> and their primitive variants (IntPredicate, etc.).
What changed? Older versions had more questions on
java.utilcollections basics (ArrayList, HashMap). The updated test heavily reduces those in favor of Stream operations (flatMap, reduce, collect), Optional misuse, and ConcurrentHashMap atomic methods.