Capgemini Interview Question

Java basics and some puzzles