Home »
MCQs »
Java MCQs
What will be the output of following Java code (5)?
57. What will be the output of following Java code?
public class Main {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("include");
sb.append("help");
System.out.println(sb);
}
}
- Error
- include
- help
- Includehelp
Answer: D) Includehelp
Explanation:
The string here is a StringBuffer hence the contents can be edited which makes the append method work on it by adding 'help' to the end of the string.