Encapsulation, JAVA Programming

Assignment Help:

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.

 

931_Untitled.png

 

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.

 


Related Discussions:- Encapsulation

What is the set interface, What is the Set interface? A Set interface i...

What is the Set interface? A Set interface is collection of element that can't be duplicated. Set interface comprise methods inherited from collection. It provides method

Describing service oriented architecture (soa)? , Service Oriented Architec...

Service Oriented Architecture Service Oriented Architecture (SOA) is an evolution of the fundamentals governing a component based development. Component based development gives

What is a portal?, A portal is a service or a Web site that gives broad ran...

A portal is a service or a Web site that gives broad range of services and resources like e-mail, forums, search engines, weather information, news, on-line shopping, stock quotes.

data integrity - security component, Data integrity helps to make sure if ...

Data integrity helps to make sure if something is communicate and not tampered with in the mean while when transmission take place. Checksums: Simply inserts the bytes withi

What is my personal agent, What is "My Personal Agent"? My personal age...

What is "My Personal Agent"? My personal agent is a computer programme which work automatically and have voice interface.

Java, Write a program called Power that displays the positive powers of 2. ...

Write a program called Power that displays the positive powers of 2. When the user enters the exponent at a prompt, the program displays 2 to that power. The program halts when the

Javaserver faces navigation model, What is JavaServer Faces navigation mode...

What is JavaServer Faces navigation model? Ans) A mechanism for describing the sequence in which pages in a JavaServer Faces application are shown.

Recursive Division Maze Generation, can you tell me what the code for a 2d ...

can you tell me what the code for a 2d random java array using Recursive Division Maze Generation

State about the garbage collection, Explain garbage collection. Java us...

Explain garbage collection. Java uses garbage collection to free the memory. By cleaning those objects which is no longer reference by any of the program. Step involve in clean

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd