Twa kɔ nsɛm atitiriw so
Log in
Sign up for FREE
arrow_back
Laabri

Java Lambda & Streams Quiz

star
star
star
star
star
Last updated over 2 years ago
15 Nsɛmmisa
Single/Multiple choise:
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Untitled Section
Asemmisa {{asɛmmisaAhyɛnsode}}
1.

What is the syntax for a lambda expression in Java?

Asemmisa {{asɛmmisaAhyɛnsode}}
2.

Which of the following functional interfaces represents a function that takes an argument and returns a result?

Asemmisa {{asɛmmisaAhyɛnsode}}
3.

What is the purpose of the anyMatch() method in Java streams?

Asemmisa {{asɛmmisaAhyɛnsode}}
4.

Which of the following terminal operations does not return a value in Java streams?

Asemmisa {{asɛmmisaAhyɛnsode}}
5.

What does the sorted() method do in Java streams?

Asemmisa {{asɛmmisaAhyɛnsode}}
6.

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);

Asemmisa {{asɛmmisaAhyɛnsode}}
7.

What does the collect() terminal operation do in Java streams?

Asemmisa {{asɛmmisaAhyɛnsode}}
8.

Which functional interface represents a function that takes an argument and returns a boolean result?

Asemmisa {{asɛmmisaAhyɛnsode}}
9.

Which terminal operation is used to find the maximum element in a stream?

Asemmisa {{asɛmmisaAhyɛnsode}}
10.

Terminal short-circuiting operations are:

Asemmisa {{asɛmmisaAhyɛnsode}}
11.

Which of the following terminal operations in Java streams can produce results of type Optional?

Asemmisa {{asɛmmisaAhyɛnsode}}
12.

Which of the following Java stream intermediate operations are stateful?

Asemmisa {{asɛmmisaAhyɛnsode}}
13.

Which of the following Java stream terminal operations are stateless?

Asemmisa {{asɛmmisaAhyɛnsode}}
14.

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");

Asemmisa {{asɛmmisaAhyɛnsode}}
15.

What is the value of result after executing this code?

Function<Integer, Integer> addTwo = x -> x + 2;

int result = addTwo.apply(5);