Multiple choice technology programming languages

For concatenation of strings, which method is good, StringBuffer or String

  1. String Buffer

  2. String

  3. both

  4. none

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Java, StringBuffer is mutable and modifies the existing character sequence without creating new objects, whereas String is immutable, meaning each concatenation creates a new String object, which degrades performance during multiple operations.