- Java - Inner classes
- Java - Exceptions
- Java - Files and I/O
- Java - Methods
- Java - Regular Expressions
- Java - Date & Time
- Java - Arrays
- Java - Strings
- Java - Characters
- Java - Numbers
- Java - Decision Making
- Java - Loop Control
- Java - Basic Operators
- Java - Modifier Types
- Java - Variable Types
- Java - Basic Datatypes
- Java - Constructors
- Java - Object & Classes
- Java - Basic Syntax
- Java - Environment Setup
- Java - Overview
- Java - Home
Java Object Oriented
- Java - Packages
- Java - Interfaces
- Java - Encapsulation
- Java - Abstraction
- Java - Polymorphism
- Java - Overriding
- Java - Inheritance
Java Advanced
- Java - Documentation
- Java - Applet Basics
- Java - Multithreading
- Java - Sending Email
- Java - Networking
- Java - Serialization
- Java - Generics
- Java - Collections
- Java - Data Structures
Java Useful Resources
- Java - Examples
- Java - Discussion
- Java - Useful Resources
- Java - Quick Guide
- Java - Questions and Answers
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java - Modifier Types
Modifiers are keywords that you add to those definitions to change their meanings. Java language has a wide variety of modifiers, including the following −
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 example.
Example
pubpc class className { // ... } private boolean myFlag; static final double weeks = 9.5; protected static final int BOXWIDTH = 42; pubpc 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 −
Visible to the package, the default. No modifiers are needed.
Visible to the class only (private).
Visible to the world (pubpc).
Visible to the package and all subclasses (protected).
Non-Access Modifiers
Java provides a number of non-access modifiers to achieve many other functionapty.
The static modifier for creating class methods and variables.
The final modifier for finapzing 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.
What is Next?
In the next section, we will be discussing about Basic Operators used in Java Language. The chapter will give you an overview of how these operators can be used during apppcation development.
Advertisements