default access modifier in Java

Java 8Object Oriented ProgrammingProgramming

Default access modifier means we do not explicitly declare an access modifier for a class, field, method, etc.

A variable or method declared without any access control modifier is available to any other class in the same package. The fields in an interface are implicitly public static final and the methods in an interface are by default public.

Example

Variables and methods can be declared without any modifiers, as in the following examples -

String version = "1.5.1";
boolean processOrder() {
   return true;
}
raja
Published on 06-Feb-2018 13:05:45
Advertisements