Given the code fragments: Which code fragment, when inserted at line n1, enables the code
to print Hank?
A.
checkAge(iList, Person p -> p.getAge( ) > 40);
B.
checkAge (iList, p -> p.getAge ( ) > 40);
C.
checkAge(iList, (Person p) -> { p.getAge() > 40; });
D.
checkAge (iList, ( ) -> p. get Age ( ) > 40);
Explanation:
B.
checkAge (iList, p -> p.getAge ( ) > 40);
Definitely B.
Answer: B
// A
//checkAge(iList, Person p->p.getAge() > 40); // error
// B
//checkAge(iList, p->p.getAge() > 40); // OK
// C
//checkAge(iList, (Person p)->{p.getAge() > 40;}); // error
// D
//checkAge(iList, ()->p.getAge() > 40); // error
b