Infosys interview question

Java based question