Cognizant Interview Question

Java programs like arranging the numbers etc