Encapsulation, JAVA Programming

Defines to keeping all the related members together in an object. Specifying member variables as private may hide the methods and variables. Objects should hide their inner workings from the outside part. Good encapsulation gives code modularity by preventing objects interacting with each other in an unexpected way, which in turn builds future development and refactoring efforts easy.




Being able to encapsulate members of a class is important for integrity and security. We may protect variables from unacceptable values. The sample code above describes how encapsulation may be used to protect the MyMarks object from having negative values. Any modification to member variable "vmarks" can only be laid out through the setter method setMarks(int mark). This prevents the object "MyMarks" from needing any negative values by throwing an exception.


Posted Date: 7/25/2012 1:29:10 AM | Location : United States

Related Discussions:- Encapsulation, Assignment Help, Ask Question on Encapsulation, Get Answer, Expert's Help, Encapsulation Discussions

Write discussion on Encapsulation
Your posts are moderated
Related Questions
How can I improve the performance of a java application , describe the java optimization techniques?

This exercise will give you some introductory exposure to network programming with sockets. Your task is to demonstrate a minimal server program and client program that can send on

For this assignment you are provided with a class called LNode which can be used as a list node for a linked list of ints. You are also provided with an abstract class called LList

Sal?s Pizza wants to install a system to record orders for pizza and Buffalo chicken wings. When regular customers call Sal?s Pizza on the phone, they are asked their phone number.

implementation of DT in netbeans

Explain the Order of Evaluation of Logic Operators ? When Java sees a && operator or a ||, the expression on the left side of the operator is evaluated first. For instance, con

The benefits of Spring are as follows: ? Spring has layered architecture. Use what you require and leave you don't require now. ? Spring Enables POJO Programming. There is no

Online music store that stores information about song, artist, album, customer, playlist. Also all necessary diagrams - use case, uml, erd

There are four different parts by which autowiring can be done. ? byName ? constructor ? autodetect ? byType