Intermediate Java
Q71 / 100

What is the difference between StringBuilder and StringBuffer?

Correct! Well done.

Incorrect.

The correct answer is B) StringBuilder is not thread-safe but faster; StringBuffer is thread-safe but slower

B

Correct Answer

StringBuilder is not thread-safe but faster; StringBuffer is thread-safe but slower

Explanation

StringBuffer methods are synchronized, making it thread-safe but slower. StringBuilder is unsynchronized and preferred for single-threaded string manipulation.

Progress
71/100