← Quiz: Lambdas and Functional Interfaces: all 10 questions
Quiz: Lambdas and Functional Interfaces · Question 6 of 10
Which is a valid lambda for Function<Integer, Integer?
Which is a valid lambda for Function<Integer, Integer>?
- A.x -> { x * 2; }
- B.x -> { return x * 2; }
- C.(x, y) -> x * 2
- D.-> x * 2
Answer & explanation
Correct answer: x -> { return x * 2; }
A block body needs an explicit return; the other options have wrong syntax or the wrong number of parameters.
Can you get the rest right without peeking?
Take the timed Quiz: Lambdas and Functional Interfaces quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →