Results 1 to 5 of 5

Thread: What are the different types of access modifiers in JAVA?

  1. #1
    Join Date
    Feb 2009
    Posts
    5

    What are the different types of access modifiers in JAVA?

    Hello,

    What are the different types of access modifiers in JAVA?

  2. #2
    Join Date
    Apr 2008
    Posts
    1,949

    Re: What are the different types of access modifiers in JAVA?

    Java Access Modifiers (also known as Visibility Modifiers) regulate access to classes, fields and methods in Java. These modifiers determine whether a field or method in a class, can be used or invoked by another method in another class or sub-class. Access modifiers can be used to
    restrict access, and therefore functionality, to certain classes and methods; often to enhance data integrity and prevent unauthorized alteration or execution of fields and methods of the particular object. Access modifiers are an integral part of object-oriented programming.

    Thus, in summary, properties of Access modifiers:

    - regulate access to classes, fields and methods

    - can restrict access to certain classes and methods

    - they are the integral part of object-oriented programming

    In Java, access modifiers are declared with the class, method or field.

  3. #3
    Join Date
    Jun 2008
    Posts
    144

    Re: What are the different types of access modifiers in JAVA?

    Private : It can access with in the class only
    public : It can Access Any where
    protected : It can access with in the package and sub class of the package also
    default : it access with in the package only.

  4. #4
    Join Date
    May 2008
    Posts
    2,393

    Re: What are the different types of access modifiers in JAVA?

    - Default Access
    - The package Access Modifier
    - The protected Access Modifier
    - The public Access Modifier
    - The public-read Access Modifier
    - The public-init Access Modifier

    http://java.sun.com/javafx/1/tutorials/core/modifiers/

  5. #5
    Join Date
    Oct 2005
    Posts
    2,394

    Re: What are the different types of access modifiers in JAVA?

    .. keywords that help set the visibility and accessibility of a class, its member variables, and methods.
    If a class has public visibility, the class can be referenced by anywhere in the program. If a class has package visibility, the class can be referenced only in the package where the class is defined. If a class has private visibility, (it can happen only if the class is defined nested in an other class) the class can be accessed only in the outer class.

    If a variable is defined in a public class and it has public visibility, the variable can be reference anywhere in the application through the class it is defined in. If a variable has package visibility, the variable can be referenced only in the same package through the class it is defined in. If a variable has private visibility, the variable can be accessed only in the class it is defined in.

    If a method is defined in a public class and it has public visibility, the method can be called anywhere in the application through the class it is defined in. If a method has package visibility, the method can be called only in the same package through the class it is defined in. If a method has private visibility, the method can be called only in the class it is defined in.

Similar Threads

  1. public, private, protected access modifiers in OOP
    By Bol-Bacchan in forum Software Development
    Replies: 5
    Last Post: 09-03-2011, 04:43 PM
  2. Different types of internet access on LAN
    By Sandroo in forum Networking & Security
    Replies: 5
    Last Post: 27-03-2010, 11:55 AM
  3. Multiple generic types in java
    By Maya Angelou in forum Software Development
    Replies: 5
    Last Post: 11-03-2010, 12:11 PM
  4. JAVA incomaptible types
    By Daren in forum Software Development
    Replies: 1
    Last Post: 05-10-2009, 02:27 AM
  5. Types of different JDBC driver in JAVA technology
    By GunFighter in forum Software Development
    Replies: 3
    Last Post: 11-09-2009, 02:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •