Infosys Java Interview Coding Question