Sunday, June 22, 2014

Encapsulation in java

encapsulation in Java | what is encapsulation | example of encapsulation

Encapsulation is a concept of object oriented programming which define as a process of wrapping code and the data together into a single unit. Or we can say that “It is the process of binding data members (variables,  properties) and member function (methods) into a single unit”
In Java the basis of encapsulation is the class. When we design a class in Object Oriented Programming (OOPs) like Java, the first thing we should have in mind is encapsulate it. There are several benefits, given below: -
  • Better Maintainability
  • Achieve Data Hiding

Example of Encapsulation in Java:  -

java exampleEncapsulation in java

                                          Figure: -Example of encapsulation in java

No comments:

Post a Comment