Spring naar navigatie Spring naar inhoud

Abstract classes and interfaces are used to define a blueprint for other classes to follow. An abstract class is a class that cannot be instantiated on its own and is meant to be inherited by other classes.

Encapsulation is the concept of hiding the internal implementation details of an object from the outside world. This is achieved by using access modifiers such as public, private, and protected.

class ElectricCar(Car): def __init__(self, color, brand, model, battery_capacity): super().__init__(color, brand, model) self.battery_capacity = battery_capacity

print(rectangle.area()) # Output: 20 print(circle.area()) # Output: 28.26

def start_engine(self): print("The engine is started.")