Capgemini interview question

Oops question with code implementation.