The StringBuffer class in Java is used to create mutable (modifiable) string objects. Unlike String, which is immutable, StringBuffer allows changes to characters, length, and content without creating new objects. It is also thread-safe and synchronized.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which of the following creates an empty StringBuffer with default capacity?
Correct
Incorrect
Question 4 of 15
4. Question
Which method is used to add text at the end of a StringBuffer?
Correct
Incorrect
Question 5 of 15
5. Question
What is the default capacity of a newly created StringBuffer?
Correct
Incorrect
Question 6 of 15
6. Question
Which method returns the current length of the StringBuffer?
Correct
Incorrect
Question 7 of 15
7. Question
Which method can insert text at a specified index in StringBuffer?
Correct
Incorrect
Question 8 of 15
8. Question
How do you delete characters from a StringBuffer?
Correct
Incorrect
Question 9 of 15
9. Question
Which of the following methods reverses the characters in a StringBuffer?
Correct
Incorrect
Question 10 of 15
10. Question
What happens when the capacity of StringBuffer is exceeded?
Correct
Incorrect
Question 11 of 15
11. Question
Which of the following is TRUE about StringBuffer and StringBuilder?
Correct
Incorrect
Question 12 of 15
12. Question
Which method sets the character at a specific index?
Correct
Incorrect
Question 13 of 15
13. Question
Which method is used to get the internal capacity of the buffer?
Correct
Incorrect
Question 14 of 15
14. Question
What is returned by the toString() method of StringBuffer?
Correct
Incorrect
Question 15 of 15
15. Question
Which method replaces a sequence of characters in StringBuffer?
Correct
Incorrect
Summary
The StringBuffer class is an essential tool for managing dynamic string content in a thread-safe manner. It supports methods like append(), insert(), delete(), and reverse() for efficient string manipulation and is preferred when string modifications are frequent and concurrent use is expected.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.