Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



What are the different types of access modifiers in JAVA?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 25-02-2009
Member
 
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?

Reply With Quote
  #2  
Old 25-02-2009
Member
 
Join Date: Apr 2008
Posts: 1,947
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.
Reply With Quote
  #3  
Old 25-02-2009
Member
 
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.
Reply With Quote
  #4  
Old 25-02-2009
Member
 
Join Date: May 2008
Posts: 2,383
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/
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #5  
Old 25-02-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: What are the different types of access modifiers in JAVA?

Quote:
.. 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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What are the different types of access modifiers in JAVA?"
Thread Thread Starter Forum Replies Last Post
public, private, protected access modifiers in OOP Bol-Bacchan Software Development 5 09-03-2011 04:43 PM
Different types of internet access on LAN Sandroo Networking & Security 5 27-03-2010 11:55 AM
Multiple generic types in java Maya Angelou Software Development 5 11-03-2010 12:11 PM
JAVA incomaptible types Daren Software Development 1 05-10-2009 02:27 AM
Types of different JDBC driver in JAVA technology GunFighter Software Development 3 11-09-2009 02:11 PM


All times are GMT +5.5. The time now is 06:57 PM.