Question
class output {
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello World");
s1.insert(6 , "Good ");
System.out.println(s1);
}
}
What is the output of this program?
class output {
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello World");
s1.insert(6 , "Good ");
System.out.println(s1);
}
}
Answer: Option D
Was this answer helpful ?
The insert() method inserts one string into another. It is overloaded to accept values of all
simple types, plus String and Objects. Sting is inserted into invoking object at specified
position. "Good " is inserted in "Hello World" T index 6 giving "Hello Good World".
output:
$ javac output.java
$ java output
Hello Good World
Was this answer helpful ?
Submit Solution