Java SE 11 Developer (1Z0-819) — Question 38

Given the code fragment:
public void foo(Function<Integer, String> fun) {...}
Which two compile? (Choose two.)

Answer options

Correct answer: A, F

Explanation

Option A is valid as it uses a lambda expression that matches the expected Function<Integer, String> type. Option F is also correct as it uses a method reference that refers to the method Integer::toHexString, which matches the required function signature. The other options either use incorrect syntax or do not conform to the expected function type.