The Java keywords that control the accessibility of a class and class members (variables, methods, and inner classes) are as follows:
The abstract modifier. An abstract method declares just the return type and parameter list of a method, not its body. Any class that contains an abstract method must be declared abstract, but note that a class can be declared abstract without containing any abstract method. Interfaces are always abstract, but the keyword is optional in the declaration. Variables can't be declared abstract. The final modifier. A final method can't be overridden, and the value of a final variable cannot change after initialization. A local variable or method parameter must be declared final if an inner class declared inside a method will use it. A class can be declared final, in which case it cannot be extended. The static modifier. Methods, variables, and nested classes can be declared static, in which case, they belong to the class as a whole, not any particular instance. Blocks of code outside a method can be declared static to initialize static variables. The synchronized modifier. Methods and code blocks can be declared synchronized to prevent more than one thread from executing the code at the same time. When used with a code block, synchronized must be applied to an object.
|