Capgemini interview question

Java and oops based question