Abstraction, encapsulation, inheritance and polymorphism





Abstraction, encapsulation, inheritance and polymorphism
Abstraction, encapsulation, inheritance and polymorphism are four core concepts of object-oriented programming. Abstraction is the process of hiding details from the user to simplify the use of a system. For example, when you use a remote control to turn on the television, you don’t need to know how the television works in order to use it. Encapsulation is the process of packaging data and methods into an object. This allows the data and methods to be used together, and helps prevent data from being accessed or modified in an unintended way. For example, a car is a type of encapsulation. It contains many parts that work together to make the car move. Inheritance is the concept of an object “inheriting” characteristics and behaviors from another object. This allows the object to take on the characteristics of the parent object. For example, a car might have the same characteristics as a truck, but with some different behaviors. Polymorphism is the ability for an object to take on multiple forms. For example, a car can be a sedan, a coupe, a hatchback, etc. Each type of car has the same basic characteristics, but different behaviors and characteristics. Fun fact: Abstraction, encapsulation, inheritance, and polymorphism are sometimes referred to as the four pillars of object-oriented programming.