🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Strings: all 10 questions

Quiz: Java Strings · Question 8 of 10

You need a changeable string that several threads modify at the same time. Which class fits?

You need a changeable string that several threads modify at the same time. Which class fits?

  1. A.String
  2. B.StringBuilder
  3. C.char
  4. D.StringBuffer
Answer & explanation

Correct answer: StringBuffer

StringBuffer's methods are synchronized, so it is thread-safe; StringBuilder is faster but not thread-safe.

Can you get the rest right without peeking?

Take the timed Quiz: Java Strings quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →