Here are 10 essential multiple-choice questions on Java String Classes, covering key concepts.
Question 3
Which of the following will compile successfully?
StringBuffer sb = "Hello";
Question 4
Which class should be used when multiple threads need to modify the same string?
Question 5
What will be the output of the following code?
String s1 = "Java";
String s2 = s1.concat(" Programming");
System.out.println(s1);
Question 7
What will be the output of the following code?
StringBuilder sb = new StringBuilder("Hello");
sb.append(" World");
System.out.println(sb);
Question 10
What will be the output of the following code?
StringBuffer sb1 = new StringBuffer("Java");
StringBuffer sb2 = sb1;
sb1.append(" Programming");
System.out.println(sb2);
There are 10 questions to complete.
Quiz about Java String Classes