Java Access Modifiers Flashcards
Access levels affect you in two ways. First, when you use classes that come from another source, such as the classes in the Java platform, access levels determine which m_________ of those classes your own classes can use.
Second, when you write a class, you need to decide what access level every member variable and every method in your class should have.
members
Public/package-private - Class
A class will either have a ‘public’ modifier and be visible e____________,
e.g. public class Dog {
or it won’t have a modifier meaning that it (the default, also known as p_____-p_______), is visible only within its own package’
e.g. class Dog {
everywhere
package-private
Public/Private/Protected - Members (variables, methods)
There are three access modifiers that can be used for m_______ of a Java class.
1) Public
= a public member can be accessed by everything, everywhere
2) Private
= Private members can only be accessed in their own c________
3) Protected
= A protected member can only be accessed within its own p_______ and by a s_______ of its class in another package.
members
class
package
subclass
Default Package S______
If there is no modifier then we are using the default, also known as package-private, it is visible only within its own package
scope