🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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>?

  1. A.x -> { x * 2; }
  2. B.x -> { return x * 2; }
  3. C.(x, y) -> x * 2
  4. 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 →