Java SE 8 Programmer II — Question 17

Given the code fragment:
List<String> nL = Arrays.asList("Jim", "John", "Jeff");
Function<String, String> funVal = s -> "Hello : ".contact(s); nL.Stream()
.map(funVal)
.peek(System.out::print);
What is the result?

Answer options

Correct answer: C

Explanation

The code will not produce any output because the method 'contact' does not exist; it should be 'concat'. Thus, a compilation error occurs, making option C the correct answer. Options A and B imply outputs that would only occur if the code were correct, while option D misstates the nature of the error.