Chapter 8: Lambda and Functional Interfaces Flashcards
Supplier<T> is a functional interface in Java 17.</T>
True
The return type of the get() method in Supplier<T> is always void.</T>
False – The return type is T, representing a value of any type.
The get() method in Supplier<T> requires exactly one parameter.</T>
False – The get() method takes zero parameters.
Supplier<T> can be used to supply values on demand.</T>
True
Supplier<T> was introduced in Java 17.</T>
False – Supplier<T> was introduced in Java 8.</T>
Can lambda parameters in Java be declared without explicitly stating their types?
Yes. If the compiler can infer the types from the context, you can omit them in the lambda expression.
Is it allowed to mix inferred and explicit types in a single lambda expression in Java?
No. All parameters must either have their types explicitly declared or all must be inferred — mixing is not allowed.
What enables Java to allow type-less parameter declarations in lambdas?
Java’s type inference mechanism determines parameter types from the target functional interface’s method signature.