Which of the following is immutable in Java?
What is the key difference between StringBuffer and StringBuilder?
StringBuffer is thread-safe, StringBuilder is not
StringBuilder is synchronized, StringBuffer is not
StringBuffer is immutable, StringBuilder is mutable
StringBuilder consumes more memory than StringBuffer
Which of the following will compile successfully?
Java
StringBuffer sb = "Hello";
Only if sb is declared as final
Which class should be used when multiple threads need to modify the same string?
What will be the output of the following code?
Java
String s1 = "Java";
String s2 = s1.concat(" Programming");
System.out.println(s1);
Which of the following methods exists in StringBuffer but not in String?
What will be the output of the following code?
Java
StringBuilder sb = new StringBuilder("Hello");
sb.append(" World");
System.out.println(sb);
Which is the fastest for string modifications in a single-threaded environment?
What happens if multiple threads try to modify a StringBuilder instance?
It will throw a ConcurrentModificationException
It may cause unexpected results due to lack of synchronization
It will execute sequentially
It will behave the same as StringBuffer
What will be the output of the following code?
Java
StringBuffer sb1 = new StringBuffer("Java");
StringBuffer sb2 = sb1;
sb1.append(" Programming");
System.out.println(sb2);
There are 10 questions to complete.
Take a part in the ongoing discussion
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4