A concept aiming to overcome large codebase where objects communicate with each other a lot.
Each object should only expose a high-level mechanism for using it, in which this mechanism should hide internal implementation details and only reveal operations that are relevant for the other objects.
It is like a small set of public methods where other class can call without “knowing” how they work.
Inheritance:
To reuse common variables and extract unique variable into a separate class.
Form hierarchy by creating parent class and child class.
Child class can access all private variables and methods from parent class, and can also have their own variables and methods.
Polymorphism:
Provides a way to use a class exactly like its parent class so there will be no confusion with mixing types.
A parent class outlines a bunch of common methods, then each child class implements its own version of these methods.
Encapsulation:
A binding between private state and public methods.
When each object inside a class keeps its state private, other objects don’t have direct access to this state. Instead, they can only call a list of public methods.
Other classes cannot use the private objects. They can use the methods provided, but cannot change the state.
Describe each of the below
Abstraction, Inheritance, Polymorphism and Encapsulation.