7.1-2_Access Modifiers Flashcards

1
Q

What are the four access modifiers Java offers?

A

private | default | protected | public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does private modifier means?

A

Methods/Fields can be called only from within the same class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does protected modifier means?

A

Methods/Fields can be called only from within the same class/package and sub-classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly