Object
Object
Example in Python
# Encapsulation
class Car:
def get_speed(self):
# Inheritance
class ElectricCar(Car):
def charge(self):
print(f"{self.brand} is charging.")
# Polymorphism
class PetrolCar(Car):
def refuel(self):
print(f"{self.brand} is refueling.")
# Object Creation
# Accessing Methods
print(tesla.get_speed()) # Encapsulation
tesla.charge() # Inheritance
bmw.refuel() # Polymorphism
OOP Benefits