30 April 2012

Java Modifier Types


Modifiers are keywords that you add to those definitions to change their meanings. The Java language has a wide variety of modifiers, including the following:
  • Java Access Modifiers
  • Non Access Modifiers
To use a modifier, you include its keyword in the definition of a class, method, or variable. The modifier precedes the rest of the statement, as in the following examples (Italic ones):
public class Name {
   // ...
}
private int i;

static final double mark =60.5;

protected static final int age = 20;

public static void main(String[] arguments) { 
 
        // body of method
}

Access Control Modifiers:

Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors. The four access levels are:
  1. Visible to the package. the default. No modifiers are needed.
  2. Visible to the class only (private).
  3. Visible to the world (public).
  4. Visible to the package and all subclasses (protected).

Non Access Modifiers:

Java provides a number of non-access modifiers to achieve many other functionality.
  • The  static modifier for creating class methods and variables
  • The final modifier for finalizing the implementations of classes, methods, and variables.
  • The abstract modifier for creating abstract classes and methods.
  • The synchronized and volatile modifiers, which are used for threads.

3 comments:

shasthika said...

Modifiers are keywords that you add to those definitions to change their meanings.
java training in chennai | java training with placement

Geetha Devi said...

Very informative ..i suggest this blog to my friends..Thank you for sharingjava training in chennai | chennai's no.1 java training in chennai | best java institute in chennai

shasthika said...

perfect explanation about java programming .its very useful.thanks for your valuable information.java training in chennai | java training in velachery

Post a Comment

Related Posts with Thumbnails

Popular Posts

 
;