Morgan Stanley interview question

Basic java