Question
class output {
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello");
StringBuffer s2 = s1.reverse();
System.out.println(s2);
}
}
What is the output of this program?
class output {
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello");
StringBuffer s2 = s1.reverse();
System.out.println(s2);
}
}
Answer: Option B
Was this answer helpful ?
reverse() method reverses all characters. It returns the reversed object on which it was called.
Output:
$ javac output.java
$ java output
olleH
Was this answer helpful ?
Submit Solution