Amdocs interview question

How to code a program to get the reverse of a string?

Interview Answers

Anonymous

28 Apr 2020

//Reverse a String public class Reverse { public static void main(String[] args) { String s = "Selenium"; String rev =""; for(int i=s.length();i>0;i--) { rev =rev+s.charAt(i-1); } System.out.println(rev); }

2

Anonymous

26 May 2018

Wrote down the logic, explained the process and then wrote the code. They were expecting the same.

1