7.1-2_Access Modifiers Flashcards
1
Q
What are the four access modifiers Java offers?
A
private | default | protected | public
2
Q
What does private modifier means?
A
Methods/Fields can be called only from within the same class.
3
Q
What does default modifier means?
A
When there is no access modifier defined, the Methods/Fields can be called only from same class and classes in the same package.
🤯️ This one is tricky because there is no keyword for default access.
4
Q
What does protected modifier means?
A
Methods/Fields can be called only from within the same class/package and sub-classes.
5
Q
What does public modifier means?
A
Methods/Fields can be called from any class. (same class/package, sub-classes and any package regardless)