employer cover photo
employer logo
employer logo

Thinkitive Technologies

Engaged employer

Thinkitive Technologies interview question

Program to reverse the string

Interview Answers

Anonymous

Dec 4, 2020

import java . lang . *; import java . io . *; import java . util .*; class ReverseString { public static void main(string[] args) { String input = "Vinayak" byte[] strAsByteArray = input . getBytes(); byte[] result = new byte[strAsByteArray.length]; for(int i = 0; i < strAsByteArray.length; i++) result[i] = strAsByteArray[strAsByteArray.length - 1 - 1]; System.out.println(new String(result)); Output: kayaniV

3

Anonymous

Dec 12, 2020

Char[] ch=str.tocharArray(); For(int i=ch.length; i>=0;i--) { Rev=rev+ ch.charAt(i); }

1