Multiple choice

Which of the following statements is INCORRECT with reference to StringBuilder class?

  1. StringBuilder represents a mutable string of characters.

  2. StringBuilder should be used when we want to make a significant number of changes to a string.

  3. If characters are added to the StringBuilder object, its length increases at runtime.

  4. We should always use StringBuilder in place of String.

  5. We can remove characters from a StringBuilder at runtime.

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

Although the StringBuilder class generally offers better performance than the String class, we should not always replace String with StringBuilder. It depends on whether we want to edit the string during the runtime or not.