0 votes
in JAVA by
Which of the following is a valid method reference in Java 8?

a) (args) -> System.out::println

b) (args) -> Math.abs

c) (args) -> Integer::valueOf

d) (args) -> String::split

1 Answer

0 votes
by
Answer: c) (args) -> Integer::valueOf.

Explanation: A method reference is a shorthand syntax for a lambda expression that calls a method. In this case, the method reference Integer::valueOf refers to the static method valueOf() of the Integer class, which takes a String argument and returns an Integer object.
...