IOSR Journal of Computer Engineering (IOSR-JCE) e-ISSN: 2278-0661, p- ISSN: 2278-8727Volume 15, Issue 1 (Sep. - Oct. 2013), PP 59-66 www.iosrjournals.org www.iosrjournals.org 59 | Page "Study of Java Access Control Mechanism” Manhal Mohammad Basher (Department Of Mechanical, Technical Institute / Foundation of Technical Education, Iraq) Abstract: a class as "a collection of data and methods." One of the important object-oriented techniques is hiding the data within the class and making it available only through the methods. This technique is known as encapsulation because it seals the data (and internal methods) safely inside the "capsule" of the class, where it can be accessed only by trusted users. Another reason for encapsulation is to protect your class against accidental or willful stupidity. A class often contains a number of interdependent fields that must be in a consistent state. If you allow a users to manipulate those fields directly, he may change one field without changing important related fields, thus leaving the class in an inconsistent state. If, instead, he has to call a method to change the field, that method can be sure to do everything necessary to keep the state consistent. Similarly, if a class defines certain methods for internal use only, hiding these methods prevents users of the class from calling them. The goal is : All the fields and methods of a class can always be used within the body of the class itself. Java defines access control rules that restrict members of a class from being used outside the class that is done through keeping the data (and internal methods) safely inside the "capsule" of the class, where it can be accessed only by trusted users. Keywords: Encapsulation, Access Control, Classes, Constructors, Methods. I. Introduction Every time you download a ―normal‖ program, you are taking a risk, because the code you are downloading might contain a virus, Trojan horse, or other harmful code. At the core of the problem is the fact that malicious code can cause its damage because it has gained unauthorized access to system resources. For example, a virus program might gather private information, such as credit card numbers, bank account balances, and passwords, by searching the contents of your computer’s local file system. In order for Java to enable applets to be downloaded and executed on the client computer safely, it was necessary to prevent an applet from launching such an attack. Java supplies a rich set of access specifiers. Some aspects of access control are related mostly to encapsulation, inheritance and packages. Also Java’s access specifiers are public, private, and protected. Java also defines a default access level. protected applies only when inheritance is involved. Encapsulation links data with the code that manipulates it. However, encapsulation provides important attribute: access control. Through encapsulation, you can control what parts of a program can access the members of a class. By controlling access, you can prevent misuse. Also it is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding. II. Theory Part 2.1 Object-Oriented Programming Object-oriented programming (OOP) is at the core of Java. In fact, all Java programs are to at least some extent object-oriented. OOP is so integral to Java that it is best to understand its basic principles before you begin writing even simple Java programs. There are Four OOP Principles All object-oriented programming languages provide mechanisms that help you implement the object- oriented model. They are abstraction, encapsulation, inheritance, and polymorphism. We are talking about encapsulation and inheritance because these two things is related with Access Control that is related with computer network and internet. 2.1.1 Encapsulation Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. One way to think about encapsulation is as a protective wrapper that prevents the code and data from being arbitrarily accessed by other code defined outside the wrapper. Access to the code and data inside the wrapper is tightly controlled through a well-defined interface. A class defines the