HCLTech Interview Question

Was asked to code an overiding example.