Describe about the term access protection, JAVA Programming

Assignment Help:

Describe about the term Access Protection ?

Global variables are a typical cause of bugs in most programming languages. A few unknown function can modify the value of a variable while the programmer isn't expecting it to change. This plays all sorts of havoc.

Most OOP languages involving Java permit you to protect variables from external modification. This permit you to guarantee in which your class remains consistent along with what you think it is as long as the techniques of the class themselves are bug-free. For instance, in the Car class we'd like to make sure that no block of code in a few other class is permited to make the speed greater than the maximum speed. We need a way to make the subsequent illegal:

Car c = new Car("New York A234 567", 100.0);
c.speed = 150.0;
This code violates the constraints we've placed on the class. We need to permit the compiler to enforce these constraints.

A class presents a picture of itself to the world. (This picture is sometimes known as an interface, other than the word interface has a more exact meaning in Java.) This picture says in which the class has certain methods and certain fields. Everything else about the class involved the detailed workings of the class's methods are hidden. As long as the picture the class displays to the world doesn't change, the programmer can change how the class implements that picture. Among other advantages this permit the programmer to change and improve the algorithms a class uses without worrying that a few piece of code depends in unforeseen ways on the details of the algorithm used. This is known as encapsulation.

Another way to think about encapsulation is in which a class signs a contract along with all the other classes in the program. This contract says in which a class has methods with unambiguous names that take particular types of arguments and return a particular type of value. The contract might also say that a class has fields along with given names and of a given type. However the contract does not specify how the methods are implemented. However, it does not say that there aren't other private fields and methods that the class may use. A contract guarantees the presence of certain methods and fields. It does not exclude all other techniques and fields. This contract is implemented by access protection. Every class, field and techniques in a Java program is defined as either public, private, protected or unspecified.

You're closer to your immediate family (your parents and your children) than you are to your cousins. You're closer to your cousins than to the common public at large, but there are some things you don't tell anybody. Therefore, your family is not my family.


Related Discussions:- Describe about the term access protection

Program to change base system, Write a program called BaseConverter that pr...

Write a program called BaseConverter that prompts (asks) the user for a base 10 number and another number, between 2 and 10 inclusive. This second number is the base to which to co

Polymorphism carbonfootprint interface program, (CarbonFootprint Interface:...

(CarbonFootprint Interface: Polymorphism) Using interfaces, as you learned in this chapter, you can specify similar behaviors for possibly disparate classes. Governments and compan

Write short notes on (i) rmi and (ii) corba, Question 1 Write a program in...

Question 1 Write a program in Java to find the highest of any five numbers. How do you compile and execute this Java program? Question 2 Write a program to explain the Except

#, Consider the following code? What input is needed for x in order for the...

Consider the following code? What input is needed for x in order for the sum variable that is output at the end of the code to be 12 ? (In other words: what do I need to make X be

Explain the use and purpose of java adapter classes, Question: (a) Exp...

Question: (a) Explain the event handling mechanism using a 'JComboBox' as example. Your answer must clearly indicate the event source, event object and event listener. Also

A simple desktop software, A simple Desktop Software Project Description...

A simple Desktop Software Project Description: We want a tool that could convert Flash Games into HTML5 Files. These are not tedious games, very simple game. I have attached

What are the kinds of computer network, What are the kinds of computer netw...

What are the kinds of computer network according to the distance among nodes? The kinds of computer network according to the distance among nodes are: 1. LAN 2. WAN

I need 3d globe application, I need 3D Globe (Android) application Proje...

I need 3D Globe (Android) application Project Description: Seeking a talented android programmer to prepare a simple app for Android tablet display which can feature a 3D glo

Why we intrested studying social implications of creation, Why should we, a...

Why should we, as computing professionals, be interested within studying the social implications of our creations? This is important Because of remaining the track of money wis

Mobile pop-under script for mobile browsers, Project Description: Give a...

Project Description: Give a script that will produce a pop-under on a mobile landing page -We can host our own landing page and we will want to change the destination URL for

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