Java SE 11 Developer (1Z0-819) — Question 5
Which two are valid statements? (Choose two.)
Answer options
- A. BiPredicate<Integer, Integer> test = (final Integer x, var y) -> (x.equals(y));
- B. BiPredicate<Integer, Integer> test = (var x, final var y) -> (x.equals(y));
- C. BiPredicate<Integer, Integer> test = (Integer x, final var y) -> (x.equals(y));
- D. BiPredicate<Integer, Integer> test = (final var x, y) -> (x.equals(y));
- E. BiPredicate<Integer, Integer> test = (Integer x, final Integer y) -> (x.equals(y));
Correct answer: B, E
Explanation
Options B and E are valid because they correctly use the BiPredicate functional interface with proper variable type declarations. Option A fails due to the incorrect use of 'var' with a final variable, while C and D have issues with the final and var keywords, and D does not specify types for both parameters, which is required.