Chapter 8: Lambda and Functional Interfaces Flashcards

1
Q

Supplier<T> is a functional interface in Java 17.</T>

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The return type of the get() method in Supplier<T> is always void.</T>

A

False – The return type is T, representing a value of any type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The get() method in Supplier<T> requires exactly one parameter.</T>

A

False – The get() method takes zero parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Supplier<T> can be used to supply values on demand.</T>

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Supplier<T> was introduced in Java 17.</T>

A

False – Supplier<T> was introduced in Java 8.</T>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can lambda parameters in Java be declared without explicitly stating their types?

A

Yes. If the compiler can infer the types from the context, you can omit them in the lambda expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Is it allowed to mix inferred and explicit types in a single lambda expression in Java?

A

No. All parameters must either have their types explicitly declared or all must be inferred — mixing is not allowed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What enables Java to allow type-less parameter declarations in lambdas?

A

Java’s type inference mechanism determines parameter types from the target functional interface’s method signature.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly