Microsoft Interview Question
1,274 Interview Reviews |
Back to all Microsoft Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Program Manager Or Software Development Engineer at Microsoft:
Write a function that takes an input string, consisting of several words separated by spaces, and print out each word reversed, keeping the same order within the string.
See more for this Microsoft Program Manager Or Software Development Engineer Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (4)
----------------------------------------------
import java.util.StringTokenizer;
public class MsTest
{
public static void main(String[] args) {
// TODO Auto-generated method stub
String aString = "ABC 123 Doe Ray Me Fala=la 890";
System.out.println( "Original String: " + aString );
StringReverseElements( aString );
}
private static void StringReverseElements(String Mess ) {
StringTokenizer st = new StringTokenizer (Mess, " ");
String tmpString;
System.out.print( "Reversed String: " );
while (st.hasMoreTokens ())
{
tmpString = (st.nextToken());
PrintReverse( tmpString.toCharArray(), tmpString.length());
}
}
private static void PrintReverse( char[] AnArray, int iLen )
{
for ( int kk = 0; kk < iLen; kk++ )
System.out.print( AnArray [ iLen - kk -1] );
System.out.print( ' ' );
}
}
Helpful Answer?
Yes |
No
Inappropriate?
That would absolutely work, but during my interview I was told I couldn't use library functions, including Tokenizer.
Helpful Answer?
Yes |
No
Inappropriate?
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up



1 of 1 people found this helpful
by Interview Candidate: