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.

Related questions

0 votes
0 votes
asked May 12 in JAVA by rahuljain1
0 votes
asked Apr 30 in JAVA by john ganales
...