Exam 1z0-808 All QuestionsBrowse all questions from this exam
Question 47

Given the code fragments:

Which code fragment, when inserted at line n1, enables the code to print Hank?

A.

B.

C.

D.

    Correct Answer:

Discussion
Skytrix

Why id D wrong?

yanoolthecool

I answered the same thing, and I was wrong, its missing the 𝙧𝙚𝙩𝙪𝙧𝙣 keyword.

Vicky_65

C is the right one

Ankit1010

C is the correct answer

odzio33

public class Test { public static void checkAge(List<Person> personList, Predicate<Person> pearsonPredicate){ for(Person p : personList){ if(pearsonPredicate.test(p)){ System.out.println(p.name + " "); } } } public static void main(String[] args){ List<Person> personList = Arrays.asList(new Person("Hank", 45), new Person("Charlie", 40), new Person("Smith", 38) ); checkAge(personList, p -> p.getAge() > 40); } } Answer is C.

UAK94

Answer is C. import java.util.Arrays; import java.util.List; import java.util.function.Predicate; public class TestPredicate { public static void checkAge(List<Person> list, Predicate <Person> predicate ) { for (Person p:list) { if (predicate.test(p)) {System.out.println(p.name + " ");} } } public static void main(String[] args) { List<Person> iList=Arrays.asList(new Person("Hank", 45), new Person("Charlie",40), new Person("Smith", 38)); checkAge(iList, p -> p.getAge() > 40); } } Output: Hank