In Java 8 the lambda expression was introduced and it can be

In Java 8, the lambda expression was introduced and it can be used in place of an anonymous that implements an interface that defines just one method. Which of the follow statements DOES NOT have correct lambda expression syntax: Select one: a. (int a, int b) -> a + b; b. public void run() {System.out.println(“testing”)}; c. (X, Y) -> X / Y; d. () -> System.out.println(\"Hello World\");

Solution

b. public void run() {System.out.println(\"testing\")}; is not a function as it is a normal java method.

All the other lambda expressions,

(int a, int b) -> a+b;

(X, Y) -> X/Y;

() -> System.out.println(\"Hello World\");

are valid lambda functions.

In Java 8, the lambda expression was introduced and it can be used in place of an anonymous that implements an interface that defines just one method. Which of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site