- 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: String Pool & Immutability
This Java quiz tests one of the most asked interview topics, the string pool and string immutability. You will predict what == and equals() print for literals, new String(), intern() and compile-time constants, and spot the code that throws.
Beispielfrage
Frage 1 von 10What does this print?
public class Main {
public static void main(String[] args) {
String a = "hi";
String b = "hi";
System.out.println(a == b);
}
}
Lösung zeigen
B. true Identical string literals are stored once in the string pool, so a and b point to the same object and == is true. That is an implementation detail of literals, not a reason to compare strings with ==.
Darum geht es in diesem Quiz
==(same object) vsequals()(same text)- String literals and the string pool
new String()andintern()- Compile-time constant concatenation and
final - Why
Stringmethods return new strings
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.