Sail E0 Webinar
Question


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);
}
}
Options:
A .  Hello
B .  olleH
C .  HelloolleH
D .  olleHHello
Answer: Option B

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 ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers