- Ausführende
-
Lernen
Python lernen Ausführbare Beispiele, NumPy, pandas und mehr KI / Machine Learning lernenNeuronale Netze, ML und LLMs von Grund auf C/C++ lernen Zeiger, Speicher, STL und modernes C++ C# lernenC#-Grundlagen, OOP, LINQ, Async und .NET-Übungen Matplotlib lernenLinien-, Balken-, Streu- und Kreisdiagramme mit interaktiven Visualisierungen Rust lernenOwnership, Traits, Fehlerbehandlung und Threads Go lernenSlices, Interfaces, Goroutinen und Channels Python-Algorithmen Suche, Sortierung, Rekursion und Visualisierungen O(n) C/C++-Algorithmen Implementierungen in C und C++ vergleichen Programmieren für Kinder Spielend programmieren lernen!
- QuizzeNeu
- AufgabenNeu
- Für LehrkräfteNeu
- Aktualisierungen
- Spendier mir einen Kaffee
Java-Quiz: 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.
Beispielfrage
Frage 1 von 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);
}
}
Lösung zeigen
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.
Darum geht es in diesem 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
Häufige Fragen
Brauche ich ein Konto?
Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.
Kann ich es wiederholen?
Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.