Sail E0 Webinar
Question


What is the output of this program?


class output {
public static void main(String args[])
{
StringBuffer c = new StringBuffer("Hello");
StringBuffer c1 = new StringBuffer(" World");
c.append(c1);
System.out.println(c);
}
}
Options:
A .  Hello
B .  World
C .  Helloworld
D .  Hello World
Answer: Option D

 append() method of class StringBuffer is used to concatenate the string representation 

to the end of invoking string.
Output:
$ javac output.java
$ java output
Hello World



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers