- 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: Records, var & switch Expressions
This Java quiz covers the features added between Java 10 and 17 that make everyday code shorter: records, var and switch expressions. You will predict output, find code that does not compile and compare the new switch with the classic one.
Domanda di esempio
Domanda 1 di 10What does this print?
public class Main {
record Point(int x, int y) {}
public static void main(String[] args) {
Point p = new Point(3, 4);
System.out.println(p);
}
}
Mostra la risposta
B. Point[x=3, y=4] Records get a generated toString() in the form Name[field=value, ...] with square brackets. A normal class without toString() would print the class name and a hash.
Cosa copre questo quiz
- What a record generates (constructor, accessors,
equals,hashCode,toString) - Compact constructors for validation
- Where
varworks and what type it infers - Arrow
switchexpressions, multiple labels andyield - Fall-through in the classic
switchstatement
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.