Have a Question?

If you have any question you can ask below or enter what you are looking for!

What is Encapsulation?

What is Encapsulation?

What is Encapsulation?

What is Encapsulation?
  • The process of binding data and corresponding method into a single unit is nothing but encapsulation. 
  • If any component follows Data Hiding and Abstraction such type of component is said to be encapsulated component.
    • Encapsulation = Data hiding + Abstraction.
  • Encapsulation is a principle of wrapping data (variables) and codes together as a single unit. It is one of the four OOP concepts. The other three are Inheritance, Polymorphism, and Abstraction.
  • Encapsulation is the process of combining data and functions into a single unit called class. In Encapsulation, the data is not accessed directly; it is accessed through the functions present in the class. In simpler words, attributes of the class are kept private and public getter and setter methods are provided to manipulate these attributes. Thus, encapsulation makes the concept of data hiding possible.
  • The main advantage of encapsulation are:-
    1. We can achieve security.
    2. The enhancement will become easy
    3. It improves maintainability of the application.
  • The main disadvantage of encapsulation is it increases the length of the code and slows down execution.

Tightly encapsulated class

  • A class is said to be tightly encapsulated if and only if each and every variable declare as private.
  • If the parent class is not tightly encapsulated the no child class is tightly encapsulated.
Tags:  , , , , , , , ,

Leave a Reply

Your email address will not be published.