← Quiz: Lambdas and Functional Interfaces: all 10 questions
Quiz: Lambdas and Functional Interfaces · Question 4 of 10
What does this print? (code)
What does this print?
import java.util.function.*;
public class Main {
public static void main(String[] args) {
Predicate<String> longWord = s -> s.length() > 4;
Predicate<String> startsJ = s -> s.startsWith("J");
System.out.println(longWord.or(startsJ).test("Java") + " " + longWord.and(startsJ).test("Java"));
}
}
- A.true true
- B.false false
- C.true false
- D.false true
Answer & explanation
Correct answer: true false
"Java" has length 4 (not more than 4) but starts with J: or gives true, and gives false.
Can you get the rest right without peeking?
Take the timed Quiz: Lambdas and Functional Interfaces quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →