Search This Blog

Encapsulation in Java

Encapsulation 

   The process of binding data and corresponding method into a single unit. This process is called Encapsulation.

Exam.      public class Teacher{

                             data member(variable)
                                            +
                             method(behavior)
                                                                              
                                 }
     If any component follows data hiding and abstraction such type of component is set to be encapsulated component.


                               Encapsulation = Data Hiding + Abstraction


The main advantages of encapsulation are -:
                                                                  1- We can achieve security.
                                                                  2- Enhancement will become easy.
                                                                  3- It improves maintainability of the application.