Employeur impliqué
Explain OOP principles with a real-world example.
Utilisateur anonyme
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.