Gajendra interview question

Questions on core java and puzzle