Access Specifiers:
Table for Visibility of private, default, protected and public Specifiers:
Access Modifiers:
- default: accessible to the same package
- public: accessible to all
- protected: accessible to same package or subclasses of other package
- private: Accessible to same class only
Table for Visibility of private, default, protected and public Specifiers:
Access Specifier | Same Class | Non Sub-Class in same package | Sub-Class in same package | Sub-Class in different package | Non Sub-Class in different package |
---|---|---|---|---|---|
private | Y | N | N | N | N |
default | Y | Y | Y | N | N |
protected | Y | Y | Y | Y | N |
public | Y | Y | Y | Y | Y |
Access Modifiers:
- static: creating class level methods and class level variables
- abstract: creating abstract classes and methods
- final class: cannot inheritable
- final method: cannot be overridden
- final variable: After initialize cannot change the value
- synchronized and volatile: used in Multi-Threading
Members of Class | Valid Modifiers |
---|---|
Data Members | private, protected, public, no-specifier, final, static, volatile and transient |
Methods | private, protected, public, no-specifier, final, static, abstract, synchronized and default |
Constructors | private, protected, public and no-specifier |
Class | public, no-specifier, final and abstract |
Nested Classes | private, protected, public, no-specifier, final, static and abstract |
No comments:
Post a Comment