Tuesday, December 10, 2013

Modifiers In Java

It is possible to modify classes, methods, etc., by using modifiers. There are two categories of modifiers:

  • Access Control Modifiers : default, public, protected, private
  • Non Access Modifiers : static, final, abstract, synchronized



Access Control Modifiers:

Java provides access modifiers to set access levels for classes, variables, methods
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 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.

No comments:

Post a Comment

Tha 𝗔𝗣𝗜 Design 𝗛𝗮𝗻𝗱𝗯𝗼𝗼𝗸

 Here is the 𝟮𝟬𝟮𝟲 𝗔𝗣𝗜 𝗛𝗮𝗻𝗱𝗯𝗼𝗼𝗸 broken down by architecture: 𝟭. 𝗧𝗵𝗲 "𝗥𝗲𝗾𝘂𝗲𝘀𝘁-𝗥𝗲𝘀𝗽𝗼𝗻𝘀𝗲" 𝗧𝗿𝗶𝗼: ...