What is data encapsulation?
The most common example I can think of is a javabean. Encapsulation may be used by creating 'get' and 'set' methods in a class which are used to access the fields of the object. Typically the fields are made private while the get and set methods are public.
Encapsulation can be used to validate the data that is to be stored, to do calculations on data that is stored in a field or fields, or for use in introspection (often the case when using javabeans in Struts, for instance).
Subscribe to:
Post Comments (Atom)
private methods on Interface
Private methods can be used on interface from java 9. This will help in Avoiding code duplication. Ensuring code re-usab...
-
When an object is no longer referred to by any variable, java automatically reclaims memory used by that object. This is known as...
-
1. If a name has more the one word, then except the first word others should start with the uppercase. Examples : setLayout, addLayoutCompon...
-
Step 1: Create a shortcut for eclipse.exc Step 2: Right click eclipse short cut and add target value with “-vm "C:\Program Files\J...
No comments:
Post a Comment