Cognizant interview question

Few puzzles to be coded in java.