Sail E0 Webinar
Question
Select the appropriate code which reverses a word.
Options:
A .  public String reverse(String input){
B .  public String reverse(String input){
C .  public String reverse(String input){
D .  public String reverse(String input){
Answer: Option B


Although, it is possible to reverse the string without using stack, it is done by looping through the string from the end character by character.
In Java, it is also possible to use the StringBuilder and StringBuffer classes which have a built-in method 'reverse'.
Note its similarity to PalindromeTest



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers