American Express interview question

They asked a java program to reverse the function.