- Esecutori
-
Impara
Impara Python Esempi eseguibili, NumPy, pandas e altro Impara l'IA / Machine LearningReti neurali, ML e LLM da zero Impara C e C++ Puntatori, memoria, STL e C++ moderno Impara C#Fondamenti, OOP, LINQ, async ed esercizi .NET Impara MatplotlibGrafici a linee, barre, dispersione e torta con visualizzatori Impara RustOwnership, trait, gestione degli errori e thread Impara GoSlice, interfacce, goroutine e canali Algoritmi Python Ricerca, ordinamento, ricorsione e visualizzazioni O(n) Algoritmi C e C++ Confronta le implementazioni in C e C++ Programmazione per bambini Impara a programmare giocando!
- QuizNuovo
- SfideNuovo
- Per docentiNuovo
- Aggiornamenti
- Offrimi un caffè
Quiz di Java: Lambdas & Streams
This Java quiz tests lambdas and the Stream API that came with Java 8. You will predict what pipelines print, see why streams are lazy and single-use, and match lambdas to functional interfaces.
Domanda di esempio
Domanda 1 di 10What does this print?
import java.util.List;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
List<Integer> nums = List.of(1, 2, 3, 4, 5, 6);
List<Integer> result = nums.stream()
.filter(n -> n % 2 == 0)
.map(n -> n * n)
.collect(Collectors.toList());
System.out.println(result);
}
}
Mostra la risposta
A. [4, 16, 36] filter keeps the even numbers 2, 4 and 6, then map squares each of them. The original list is not changed; collect builds a new one.
Cosa copre questo quiz
filter,map,reduceandcollect- Lazy evaluation and the order in which elements flow
- Streams can be used only once
- Effectively final variables in lambdas
Collectors.joining,groupingBy,Optionaland functional interfaces
Domande frequenti
Serve un account?
No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.
Posso rifarlo?
Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.