• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Encapsulation in java

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

Here is a defination of Encapsulation from a site


Encapsulation refers to the bundling of data with the methods that operate on that data, and also some say that ENcapsulation is data hiding .

From this i understand that Encapsulation is nothing but a java bean with private properties and public methods .

Please guide me here .
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
encapsulation? Your definition is correct. It is data hiding because the class uses public getters/setting to retrieve/assign "private" variables. And the class is practically a JavaBean.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ravi Kiran V wrote:
From this i understand that Encapsulation is nothing but a java bean with private properties and public methods .



In OO, encapsulation is a little more than that. When you encapsulate something you get an inside and an outside. The outside is called a data abstraction, or the type. The inside is called information hiding, or the implementation. So in principle encapsulation is the separation of a visible type from a hidden implementation, or the division of something into "what" you can see and use, from "how" it's done. Most importantly the type and the implementation become independent of each other and can be changed separately.

The main units of encapsulation in Java is the class, the enum and the interface (each with somewhat different encapsulation properties). The type is the signature and behaviour of all non-private methods and fields of these language elements. The implementation is the code inside including private methods and fields.

Encapsulation is very important in Java. It's at the very heart of OO programming. Defining appropriate types and cleverly hiding implementation is the process that drives the design and development of Java programs.
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic