Quiz di Java: Strings & String Methods

This Java strings quiz tests the String methods you use every day and the traps around them. You will predict the output of substring, indexOf and split, compare strings the right way and see why strings never change in place.

Facile 10 domande ~5 minuti Superato con il 80% Java 17

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 10

What does this print?

public class Main {
    public static void main(String[] args) {
        String s = "Hello";
        s.toUpperCase();
        System.out.println(s);
    }
}
Mostra la risposta

B. Hello Strings are immutable: toUpperCase() returns a new string and leaves s alone. The result is thrown away here; write s = s.toUpperCase(); to keep it.

Cosa copre questo quiz

  • Strings are immutable
  • == vs equals() and equalsIgnoreCase()
  • substring, indexOf, charAt and their index rules
  • split and empty trailing strings
  • Concatenating null and using StringBuilder

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.