Complete the code to create a new StringBuilder object.
StringBuilder sb = new [1]();The StringBuilder class is used to create mutable strings in Java. Here, we create a new instance using new StringBuilder().
Complete the code to append the string "Hello" to the StringBuffer object.
StringBuffer sb = new StringBuffer(); sb.[1]("Hello");
The append method adds the given string to the end of the current StringBuffer content.
Fix the error in the code to convert StringBuilder to String.
StringBuilder sb = new StringBuilder(); sb.append("Test"); String result = sb.[1]();
The toString() method converts the StringBuilder content to a regular String.
Fill both blanks to create a StringBuffer, append "Hi", and convert to String.
StringBuffer sb = new [1](); sb.[2]("Hi"); String s = sb.toString();
We create a StringBuffer object and use append to add text.
Fill all three blanks to create a StringBuilder, append "Bye", and convert to String.
StringBuilder [1] = new StringBuilder(); [1].[2]("Bye"); String result = [1].[3]();
We name the StringBuilder sb, use append to add text, and toString() to get the String.
