26 August, 2012

Modifiers in JAVA

=>Access Modifiers :

The following are access modifiers:
private : Makes a method or a variable accessible only from within its
own class.
■ protected :Makes a method or a variable accessible only to classes in the
same package or subclasses of the class.
public Makes a class, method, or variable accessible from any other class.



=>Class, Method, and Variable Modifiers :

The following are class, method, and/or variable modifiers:
abstract : Used to declare a class that cannot be instantiated, or
a method that must be implemented by a nonabstract subclass.
class : Keyword used to specify a class.
extends : Used to indicate the superclass that a subclass is extending.
final : Makes it impossible to extend a class, override a method, or
reinitialize a variable.
implements : Used to indicate the interfaces that a class will implement.
interface : Keyword used to specify an interface.
native : Indicates a method is written in a platform-dependent language,
such as C.
new : Used to instantiate an object by invoking the constructor.
static : Makes a method or a variable belong to a class as opposed to
an instance.
strictfp : Used in front of a method or class to indicate that
floating-point numbers will follow FP-strict rules in all expressions.
synchronized : Indicates that a method can be accessed by only one
thread at a time.
transient : Prevents fields from ever being serialized. Transient fields are
always skipped when objects are serialized.
volatile : Indicates a variable may change out of sync because it is used
in threads.