Which two are valid statements? (Choose two.)
Which two are valid statements? (Choose two.)
The valid statements involve parameters where the combination of data types and usage of the 'var' keyword are consistent with Java's rules for lambda parameter types. Statement (B) correctly uses 'var' for both parameters, and 'final' can be applied to 'var' parameters. Statement (E) uses explicitly typed parameters with 'final' as well, which is also valid in Java. Invalid statements either mix 'var' with explicitly typed parameters or omit necessary type declarations.
B and E are correct
Correct answer is BE
B AND E: BiPredicate<Integer, Integer> test = (final Integer x, var y) -> (x.equals(y)); => BAD MIX TYPES BiPredicate<Integer, Integer> test2 = (var x, final var y) -> (x.equals(y)); => OK BiPredicate<Integer, Integer> test3 = (Integer x, final var y) -> (x.equals(y)); => MIX BiPredicate<Integer, Integer> test4 = (final var x, y) -> (x.equals(y)); => Y NOT TYPE BiPredicate<Integer, Integer> test5 = (Integer x, final Integer y) -> (x.equals(y)); => OK
Tested: B and E.
B and E, as var parameters cannot be mixed with other (typed) parameters
BiPredicate<Integer, Integer> test = (var x, final var y) -> (x.equals(y)); BiPredicate<Integer, Integer> test2 = (Integer x, final Integer y) -> (x.equals(y));
Good definitions
BE are correct
B&E are correct