Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 119

Given the code fragment:

What is the result?

    Correct Answer: D

    A compilation error occurs at line n2 because the predicate 'test2' is not correctly parameterized. Predicate in Java generics should have a type parameter specified, such as Predicate<String>. Without this parameter, the compiler expects an Object type, leading to a compilation error.

Discussion
laura_lu93Option: D

answer is D. tested. compiler error is "lambda parameter is expected of type Object"

Tarik2190Option: D

Answer is D public class Test { public static void main (String[] args) throws InterruptedException { List<String> words = Arrays.asList("win", "try", "best", "luck", "do"); Predicate<String> test1 = w -> { System.out.println("Checking..."); return w.equals("do"); }; Predicate test2 = (String w) -> w.length() > 3; words.stream() .filter(test2) .filter(test1) .count(); } }

kartaOption: D

answer is D

WilsonKKerllOption: D

Predicate<String> test2 = (String str) -> str.length() > 3; // line n2

SigamaniOption: D

answer is D

jduarteOption: C

The correct answer is C the instructionPredicate<String> test1=w->{System.out.println(""); is ok

asdfjhfgjuaDCVOption: D

D is the correct answer

steefaandOption: D

Answer is D since Predicate is not parametrized and expects Object as input.

duydnOption: D

D is correct, Predicate<T> need a type parameter.

lchowenOption: D

Predicate is not parameterized so it is using raw type. Compilation error at line n2. Answer is D

mevltOption: C

The answer is C

SamriddjiOption: D

D, tested

Svetleto13Option: D

D,tested