27 questions for “Functional Interfaces & Method References”

Found in 1 field. Select a question to see its full answer.

Information Technology

27 questions in 2 technologies

#QuestionTechnologyTopicLevel
1How would you convert a checked-exception-throwing method into a lambda usable with a standard functional interface (which doesn't declare any checked exceptions), given standard interfaces like Function don't permit checked exceptions in their abstract method signature? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
2How does Java's type inference determine the target type for a lambda expression in an ambiguous overload scenario, and what happens when a lambda could match multiple overloaded methods accepting different functional interfaces? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced
3What is a functional interface, and what are the four core functional interfaces in java.util.function (Function, Predicate, Consumer, Supplier)? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesBeginner
4What are the four kinds of method references in Java (static, instance-bound, instance-unbound, and constructor), and how does the compiler determine which form applies? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
5How do the primitive-specialized functional interfaces (IntFunction, ToIntFunction, IntPredicate, IntUnaryOperator, etc.) avoid the performance cost of autoboxing, and when should you prefer them over the generic equivalents? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
6How would you design a fluent, chainable validation API using functional interfaces, similar to how Comparator's thenComparing() works, but for validation rules that accumulate error messages rather than short-circuiting on the first failure? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced
7How would you implement a custom functional interface with generic type parameters, and what considerations apply when designing one instead of reusing a built-in java.util.function interface? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced
8How do the default methods andThen() and compose() on Function work, and what's the difference between them for chaining transformations? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
9How does the Predicate interface's default methods and(), or(), and negate() enable composing complex boolean conditions from simpler ones? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
10How would you use BiFunction combined with Stream's reduce() to implement a custom aggregation, and how does this relate to the more general concept of a fold operation in functional programming? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced