Week 4 Flashcards
What is a package?
A package is a bundle of package.
How does a class use a package?
For a class that is created within a package, the package must be delcared in the class.
package PackageName; // Declares the package
How does one implement a package?
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
What are the different types of access for a package and how restricitve are they?
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
What are collections?
Collections are containers that groups items in a single unit.