0
0
Javaprogramming~15 mins

StringBuilder and StringBuffer in Java - Interactive Code Practice

Choose your learning style8 modes available
ads_clickPractice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new StringBuilder object.

Java
StringBuilder sb = new [1]();
🎯 Drag options to blanks, or click blank then click option
AStringBuilder
BStringBuffer
CString
DStringBuilderBuffer
Attempts:
3 left
2fill in blank
medium

Complete the code to append the string "Hello" to the StringBuffer object.

Java
StringBuffer sb = new StringBuffer();
sb.[1]("Hello");
🎯 Drag options to blanks, or click blank then click option
Ainsert
Badd
Cconcat
Dappend
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to convert StringBuilder to String.

Java
StringBuilder sb = new StringBuilder();
sb.append("Test");
String result = sb.[1]();
🎯 Drag options to blanks, or click blank then click option
Astring
BtoString
Cconvert
DtoStr
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create a StringBuffer, append "Hi", and convert to String.

Java
StringBuffer sb = new [1]();
sb.[2]("Hi");
String s = sb.toString();
🎯 Drag options to blanks, or click blank then click option
AStringBuffer
BStringBuilder
Cappend
Dinsert
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a StringBuilder, append "Bye", and convert to String.

Java
StringBuilder [1] = new StringBuilder();
[1].[2]("Bye");
String result = [1].[3]();
🎯 Drag options to blanks, or click blank then click option
Asb
Bappend
CtoString
Dbuffer
Attempts:
3 left