Tech Mahindra interview question

Basic OOPs