Pergunta de entrevista da empresa Tata Consultancy Services

Explain OOP principles with a real-world example.

Resposta da entrevista

Sigiloso

4 de dez. de 2025

OOP has 4 main principles: 1. Encapsulation – Binding data and methods. Example: A class Car hides internal details like engine logic and exposes only methods like start(). 2. Inheritance – Reusing properties from another class. Example: ElectricCar extends Car and reuses features like wheels or brakes. 3. Polymorphism – Same method behaving differently. Example: start() method works differently in DieselCar vs ElectricCar. 4. Abstraction – Showing only essential features. Example: You drive a car without seeing how the engine works internally.