Amazon interview question

logical java questions