Capgemini interview question

Java basics and some puzzles