Access Modifiers / Visibility Modifiers
PUBLIC -> PROJECT PRIVATE-> CLASS Protected -> determined by parent child relationship - NO INHERITANCE -> default -> PACKAGE - INHERITANCE -> public -> PROJECT
if non of the above are provided then it will be DEFAULT -> PACKAGE
Non Access Modifiers
2. Final
Access Modifiers & Non Access Modifiers
CLASS
public class Table{
public static DiningTable{
public static String material = "wood";
}
}Access Modifiers & Non Access Modifiers
CONSTRUCTOR
private constructor: create object in same CLASS
default constructor: create object in same PACKAGE
protected constructor: based on having inheritance
public constructor: create objects in PROJECT
Can never be static nor final (compiler error)
Access Modifiers & Non Access Modifiers
INSTANCE VARIABLES
private instance variables: CLASS
default instance variables: PACKAGE
protected instance variables: based on inheritance
public instance variables: PROJECT
static instance variable: it belongs to Class and can be called with class name
final instance variable: it has an initial value instantiated in the Class and this initial value can never be changed
Access Modifiers & Non Access Modifiers
METHODS
private methods: CLASS
default methods: PACKAGE
protected methods: based on inheritance
public methods: PROJECT
static methods: it belongs to class and can be called with class name
final methods: can not be overridden