R

Ram Sharma • 193.88K Points
Coach

Q. What will be the output of following Java code?

Code:
public class Main {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("include");
sb.append("help");
System.out.println(sb);
}
}
  • (A) Error
  • (B) include
  • (C) help
  • (D) Includehelp
  • Correct Answer - Option(D)
  • Views: 214
  • Filed under category JAVA

Explanation by: Team MCQ Buddy
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.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics