Java Lambda & Streams Quiz
star
star
star
star
star
Last updated almost 2 years ago
15 questions
Single/Multiple choise:
1
What is the syntax for a lambda expression in Java?
What is the syntax for a lambda expression in Java?
1
Which of the following functional interfaces represents a function that takes an argument and returns a result?
Which of the following functional interfaces represents a function that takes an argument and returns a result?
1
What is the purpose of the anyMatch() method in Java streams?
What is the purpose of the anyMatch() method in Java streams?
1
Which of the following terminal operations does not return a value in Java streams?
Which of the following terminal operations does not return a value in Java streams?
1
What does the sorted() method do in Java streams?
What does the sorted() method do in Java streams?
1
What is the output of the following Java stream operation?List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5);int result = numbers.stream() .filter(x -> x % 2 == 0) .mapToInt(x -> x) .sum();System.out.println(result);
What is the output of the following Java stream operation?
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5);
int result = numbers.stream()
.filter(x -> x % 2 == 0)
.mapToInt(x -> x)
.sum();
System.out.println(result);
1
What does the collect() terminal operation do in Java streams?
What does the collect() terminal operation do in Java streams?
1
Which functional interface represents a function that takes an argument and returns a boolean result?
Which functional interface represents a function that takes an argument and returns a boolean result?
1
Which terminal operation is used to find the maximum element in a stream?
Which terminal operation is used to find the maximum element in a stream?
1
Terminal short-circuiting operations are:
Terminal short-circuiting operations are:
1
Which of the following terminal operations in Java streams can produce results of type Optional?
Which of the following terminal operations in Java streams can produce results of type Optional?
1
Which of the following Java stream intermediate operations are stateful?
Which of the following Java stream intermediate operations are stateful?
1
Which of the following Java stream terminal operations are stateless?
Which of the following Java stream terminal operations are stateless?
1
What is the output of the following Java stream operation?List<String> words = Arrays.asList("apple", "orange", "grape", "melon", "banana",);String result = words.stream() .filter(s -> s.length() > 5) .findFirst() .orElse("No word found");
What is the output of the following Java stream operation?
List<String> words = Arrays.asList("apple", "orange", "grape", "melon", "banana",);
String result = words.stream()
.filter(s -> s.length() > 5)
.findFirst()
.orElse("No word found");
1
What is the value of result after executing this code?Function<Integer, Integer> addTwo = x -> x + 2; int result = addTwo.apply(5);
What is the value of result after executing this code?
Function<Integer, Integer> addTwo = x -> x + 2;
int result = addTwo.apply(5);
Untitled Section