0 votes
in JAVA by

Which of the following is not a valid lambda expression in Java 8?

a) (int x, int y) -> x + y

b) () -> “Hello, World!”

c) (String s) -> System.out.println(s)

d) (int x) -> {return x*x;}

1 Answer

0 votes
by
Answer: c) (String s) -> System.out.println(s).

Explanation: This lambda expression does not return a value, which violates the functional interface contract.

Related questions

0 votes
0 votes
asked Apr 13, 2023 in JAVA by Robin
0 votes
asked Aug 21, 2022 in JAVA by sharadyadav1986
...