Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


Which class was used before StringBuilder for similar purposes?

  1. StringBuffer

  2. String

  3. CharSequence

  4. StringMaker

The correct answer is: StringBuffer

Before the introduction of StringBuilder, StringBuffer was used for similar purposes. StringBuffer is a mutable sequence of characters that offers synchronization for use in multi-threaded environments, making it slower and less efficient than StringBuilder. Choices B, C, and D are incorrect because they do not share the same features as StringBuilder and were not commonly used for the same purposes. String and CharSequence are both immutable, meaning they cannot be modified once created, making them unsuitable for tasks that require frequent string manipulation. StringMaker is not a recognized class in Java, and therefore was not used for similar purposes before the introduction of StringBuilder.