L&T Technology Services Interview Question

They asked me to write an oop code