Quiz di Java: StringBuilder

This Java quiz covers StringBuilder, the mutable companion of String. You will predict what append(), insert(), delete() and reverse() produce and learn when a builder beats +=.

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) {
        StringBuilder sb = new StringBuilder("ab");
        sb.append("cd");
        System.out.println(sb);
    }
}
Mostra la risposta

C. abcd Unlike String, a StringBuilder is changed in place, so append() adds cd to the same object. Printing it calls toString().

Cosa copre questo quiz

  • append() chaining with different types
  • insert(), delete() and reverse()
  • Why equals() on two builders is false
  • StringBuilder vs += in loops
  • StringBuilder vs StringBuffer

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.