Wildcards Flashcards

1
Q

What is the purpose of an import statement ?

A

Import statements tell Java which packages to look in for classes

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

What is the purpose of packages ?

A

Containment: Packages serve as containers for classes, interfaces, and sub-packages, helping to group related functionalities together.

Organization: They provide a structured way to manage and organize code, making it easier to locate and use classes, especially in larger applications.

Namespace Management: Packages help avoid naming conflicts by providing a namespace for classes. For instance, you can have classes with the same name in different packages.

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

Define the following sentence “ Package names are hierarchical” !

A

The sentence “Package names are hierarchical” means that Java package names are structured in a nested manner, similar to a directory structure in a file system.

Hierarchy:

Package names are composed of multiple components separated by dots (.). For example, in the package name com.example.project, com is the top-level package, example is a sub-package within com, and project is a sub-package within example.

Organization:

This hierarchical structure helps organize classes and interfaces logically, making it easier to manage and locate related components.

Namespace Management:

The hierarchy also helps avoid naming conflicts by allowing packages with the same name to coexist in different levels of the hierarchy.

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

Define the rules for package names !

A

The rule for package names is that they are mostly letters or numbers separated by dots. Technically, you’re allowed a couple of other characters between the dots. The rules are the same as for variable names

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

What is a Wildcard ?

A

an asterisk wildcard (*) is used to import all classes and interfaces from a specific package.

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

Give an important characteristic of the wildcard !

A

It doesn’t import child packages, fields, or methods; it imports only classes.

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