To which type can a lambda expression be assigned?
The functional interface is the lambda's target type.
Lambda Expressions · Exercise 1 of 4
Twenty multiple-choice questions on Java lambda expressions: syntax, functional interfaces, java.util.function, method references, capture rules, this, and composition. Pick an option to check your answer instantly.
To which type can a lambda expression be assigned?
The functional interface is the lambda's target type.
Which is a valid lambda expression?
Several parameters need parentheses; no parameters is written ().
How does a block-body lambda return a value?
Only an expression body returns its value implicitly.
Which functional interface takes a value and returns a boolean?
Its method is test(T).
What does a Consumer<T> do?
Its method is accept(T); it is used for side effects like printing.
Which interface represents () -> T?
get() returns a value without taking any input.
Which is true of UnaryOperator<T> and BinaryOperator<T>?
list.replaceAll takes a UnaryOperator; reduce takes a BinaryOperator.
String::toUpperCase used as a Function<String, String> is equivalent to …
The first parameter becomes the object the method is called on.
Which is a constructor reference?
It can be a Supplier
Which local variables can a lambda use?
Fields may be read and changed freely.
Timed online tests with instant scores and explanations.