Java - Encapsulation
by, 04-26-2012 at 07:09 PM (902 Views)
Among four fundamentals of OOP concepts, encapsulation is the important one. Other three included are abstraction, polymorphism and inheritance.
Encapsulation is basically a field making technique in class private which also provides an access to the fields through public methods. When fields have been declared private then no one presnt outside of the class has access, thereby fields are hided in class. This is the reason encapsulation is given another name “data hiding”.
Encapsulation might also be taken as the protective barrier which will be preventing the data or code that has randomly been accessed by those codes which are present out of the class. Code or data access is controlled tightly by the help of an interface.
Benefit provided by the encapsulation is its ability for modification of the implemented code, with no need to break down the others code. Along with such kind of feature, encapsulation provides extensibility, maintainability and flexibility to the code.