Describe the four levels of access protection, JAVA Programming

Assignment Help:

Describe the Four Levels of Access Protection ?

Any two various Java objects have one of four relations to each other. The four relations are:
• The objects are in the similar class.
• One object is a subclass of the other object's class.
• The objects are in the similar package.
• None of the above. (Both objects are members of the general public.)

These relationships are not mutually exclusive. One object could be a subclass of another object in the similar package, for example.
You can describe that of your class's members that is its fields and its methods, are accessible to other objects in each of these four groups, associative to the current class.

If you need any object at all to be able to call a techniques or change a field, declare it public.
If you want only objects in the similar class to be able to get or set the value of a field or invoke a method, declare it private.
If you need access restricted to subclasses and members of the similar package, declare it protected.
At last, to restrict access only to objects in the similar package, use no access declaration at all. This is known as "package" or "default" access, but it has no keyword. The default keyword means something else whole.
Can anyone remember what?

By default, all classes you write are in the similar package. Therefore, they are in different packages from the Java classes like System or Applet.

The public fields and techniques of an object can be accessed from anywhere the object itself can be seen. Anyone can touch an object's public members. They should be kept to a minimum. Public fields should associate very closely to the core functionality of the class. They should not show intimate details of the inner workings of the class. Except in very simple instances fields should probably not be public.

The private fields and methods of an object can only be accessed by the object itself and by other objects of the same class (siblings). An object may touch its sibling's private parts. A sibling is an object in the same class but which is not the same object.


Related Discussions:- Describe the four levels of access protection

Multithreading and networking, This assignment has two main objectives. It ...

This assignment has two main objectives. It aims to establish a basic familiarity with the Java API (Java Thread class) for creating multithreaded Java application, and the Java ne

Jsp retrive data, how to retrive data in one block from database by click ...

how to retrive data in one block from database by click data link in another block

Recursive method to print all permutations of a string, Objectives _ Cre...

Objectives _ Creating and compiling a simple program _ Designing classes _ Use of recursive algorithms _ Learn basic combinatorics   Task: string permutation Writ

Packages and interfaces, what are the advantages of packages and interface?...

what are the advantages of packages and interface? why we use them? and what is the way of using packages and interfaces complete description with examples?

What is a relational database, What is a Relational Database? Give the name...

What is a Relational Database? Give the names of any three RDBMS software? Database consist of two or more then two tables are called Relational database. Oracle dabatbase S

Write a program to perform multiplication and division, Write a program to ...

Write a program to perform multiplication and division in java? Of course Java could also do multiplication and division. Because most keyboards don't have the times and divisi

Data structures and algorithm, Create a class to implement the ArrayList co...

Create a class to implement the ArrayList collection. The name should be YourFirstNameArrayList; for example if I were creating the class then I would call it WaynesArrayList. Do

Javacard, I want to know if you can help me with a javacard programming pro...

I want to know if you can help me with a javacard programming project

Describe life cycle of thread, Describe life cycle of thread. Threads f...

Describe life cycle of thread. Threads follow the single flow of control. A thread is execution in a program. The life cycles of threads are listed below: Newborn state: A

Web-based client program, Why are JSP pages the preferred API for creating ...

Why are JSP pages the preferred API for creating a web-based client program? Because no plug-ins or security policy files are required on the client systems (applet does). Also,

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