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

Queues, we can insert elements at rear and remove at front bt my question i...

we can insert elements at rear and remove at front bt my question is that how we insert at front in circular queue

Stream as an object, What interface must an object implement before it can ...

What interface must an object implement before it can be written to a stream as an object?      Ans) An object must execute the Serializable or Externalizable interface before i

Registered objects in a rmiregistry, How to get all the registered objects ...

How to get all the registered objects in a rmiregistry? Ans) Using list method of Naming Class.

Assignment, For this Assignment, submit the following program: Create an ap...

For this Assignment, submit the following program: Create an application for an animal-fur trimming service. The business is open 15 weeks of the year, from April through July. The

Explain jakarta struts framework, Jakarta Struts is open source execution o...

Jakarta Struts is open source execution of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used

Describe java operators, Describe java operators? An operator is a symb...

Describe java operators? An operator is a symbol which operates on one or more arguments to generate a result. The Hello World program is so easy it doesn't use any operators,

How we declaring arrays in java language, How we Declaring Arrays in java l...

How we Declaring Arrays in java language? Like all other variables in Java, an array must have a exact type such as byte, int, String or double. Just variables of the appropria

Multithreading, For this assignment we will be solving the producer-consume...

For this assignment we will be solving the producer-consumer problem with a bounded buffer. You are required to implement this assignment in Java. There are three components in thi

Explain the order of evaluation of logic operators, Explain the Order of Ev...

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

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