Access Modifiers Flashcards

1
Q

4 different types of access modifiers in least to most restrictive order

A

public
protected
default
private

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

can classes and interfaces be private

A

no

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

what does it mean when a variable is private

A

hidden from the outside world

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

from where can private variables be accessed

A

within the class it was declared

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

how can private variables be accessed from outside its declared class

A

using access modifiers

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

where are default variables available

A

to any other class in the same package

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

what is a package

A

a collection of classes

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

can protected be used on a class

A

no

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

what can protected be used on

A

variables, constructors, methods

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

what are public variables accessable to

A

any other class in the same package

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

with regard to objects, where can public attributes be accessed

A

anywhere in the program that has a reference to the objevt

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

with regard to objects, where can private attributes be accessed

A

only within the class itself

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

with regard to objects, how can protected attributes be accessed

A

within the class and any subclasses

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

are setters and getters needed with protected variables in classes

A

no

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