Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 187

Which is a valid statement?

    Correct Answer: B

    The correct statement is 'BiPredicate testEquality = (var x, var y) -> (x.equals(y));'. This is because the 'var' keyword can be used for both parameters when declaring a lambda expression, ensuring that both variables have their types inferred properly. Mixing 'var' with explicit types, omitting parentheses, or incorrectly grouping the variable declarations would result in syntax errors or invalid syntax for lambda expressions.

Discussion
ASPushkin

similar to 22, 204

ASPushkinOption: B

A) there is no mix var with the explicit types B) ok C) syntax error without brackets D) compound not allowed

d7bb0b2Option: B

B: Bcos Bipredicated is declared without type and then cannot pass other Type that Object

ASPushkin

For backward compatibility, assigning a parameterized type to its raw type is allowed. BiPredicate is a raw type from generic type BiPredicate<T,U> where T and U substitute to Object. So it could be any type inherited from Object type.