Week 4 Flashcards

1
Q

What is a package?

A

A package is a bundle of package.

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

How does a class use a package?

A

For a class that is created within a package, the package must be delcared in the class.

package PackageName; // Declares the package

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

How does one implement a package?

A

For a class within a different package, the package one wants to implement must be imported. One can also import a specific class within the package.

import PackageName; // imports the specified package
import PackageName.ClassName; // Imports the specific class within a package

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

What are the different types of access for a package and how restricitve are they?

A

Protected:
* memmbers/methods are accessible for the classes and subclasses within the package

Private:
* members/methods are accessible only within the same class

No specifier:
* members/methods are accessible only to classes in the same package, not subclasses

Public:
* members/methods are accessible everywhere

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

What are collections?

A

Collections are containers that groups items in a single unit.

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