Infosys interview question

Core java only