Cognizant interview question

Java programs like arranging the numbers etc