Explain OOP principles with examples.
Anónimo
OOP has four main principles — Encapsulation, Inheritance, Polymorphism, and Abstraction. Encapsulation: Wrapping data and methods together in a class and restricting direct access. Inheritance: Deriving a new class from an existing one to reuse code. Polymorphism: The ability of an object to take many forms — achieved via method overloading and overriding. Abstraction: Hiding complex implementation details and showing only the essential features.