Abstraction is a generalized term. that is, encapsulation is a subset of abstraction.
Abstraction is a powerful methodology for managing complex systems. Abstraction is governed by clearly defined objects and their hierarchical classification.
For example, a car itself is a well-defined object, which consists of several other smaller objects, such as a transmission system, steering gear, engine, which again have their own subsystems. But for a person, a car is one single object that can be controlled using its subsystems, even if their internal details are unknown. Provided by
Encapsulation: Combining data and method elements together into a single block (such as a class) is called Encapsulation.
Encapsulation is like a shell in a capsule. This includes related operations and data associated with the object in this object.
Encapsulation is similar to your bag in which you can store your pen, book, etc. This means that this is a property of encapsulating members and functions.
class Bag{ book; pen; ReadBook(); }
Encapsulation means hiding the internal details of an object, that is, how the object does something.
Encapsulation does not allow clients to see the internal view where abstraction behavior is implemented.
Encapsulation is a method used to protect information in an object from another object.
Hide data for security, for example, make variables private, and open a property to access private data that will be public.
So, when accessing the resource, you can check the data and install it. Provided by