Multiple choice

Which of the following statements is true?

  1. StringBuilder class is faster than StringBuffer class.

  2. StringBuilder is thread safe.

  3. StringBuffer str=new StringBuffer("hello"); //creates an immutable string object "str" which contains "hello"

  4. StringBuilder is synchronized.

  5. None of the above statements is true

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

 StringBuilder is not synchronized , where as StringBuffer is synchronized. Hence StringBuilder is faster than String Buffer.