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 built canvas printing calculator, Printing Calculator Canv...

Printing Calculator Canvas Printing Calculator In this assignment we will continue to work on our canvas printing web service. Specifically we will make use of Javascrip

Calculates number of negative and positive numbers in array, Question 3 ...

Question 3 Using this line: var posneg : array [1..15] of integer; Write a program that calculates the number of negative and positive numbers in the array. Users will

What is a jsp and what is it used for?, Java Server Pages (JSP) is a platfo...

Java Server Pages (JSP) is a platform independent presentation layer technology that comes with SUN s J2EE platform. JSPs are normal HTML pages with Java code pieces embedded in th

What is testing for equality in java, What is Testing for Equality in java?...

What is Testing for Equality in java? Testing for equality is a little trickier. You would expect to test if two numbers are equal through using the = sign. However the = sign

Why use rmi when we can handle the same benefits from ejb?, EJBs are distri...

EJBs are distributed elements, which need the RMI framework for object distribution. An EJB application server gives more services like object pooling, transaction management, data

What is the use of wrapper class, What is the use of Wrapper class You...

What is the use of Wrapper class You can create an object of Wrapper class using a String or a primitive data type Integer num = new Integer (4); or Integer num = n

What is bandwidth, What is bandwidth? In a general way Bandwidth is a c...

What is bandwidth? In a general way Bandwidth is a capacity of communication channel of carrying data.

I want someone to fix some bugs in a java app, I want someone to fix some b...

I want someone to fix some bugs in a java app Project Description: I have a small app in java, but it has some issues, the app is running. But we need to make it work more st

I want solution to this question., This assignment is based on the principl...

This assignment is based on the principles of clock consistency and associated drifts in a distributed system. You have to create a simulation, running on a single machine, of a si

What is jms message, An object that having the data being transferred among...

An object that having the data being transferred among JMS clients.

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