0%

JavaSE import

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package aquarium; 
public class Water {
boolean salty = false;
}

package aquarium.jellies;
public class Water {
boolean salty = true;
}

package employee;
INSERT IMPORTS HERE
public class WaterFiller {
Water water;
}

A. import aquarium.*;

B. import aquarium.Water; import aquarium.jellies.*;

C. import aquarium.*; import aquarium.jellies.Water;

D. import aquarium.; import aquarium.jellies.;

E. import aquarium.Water; import aquarium.jellies.Water;

F. None of these imports can make the code compile.

Answers: A B C

✔︎ OptionA will incorporate all classes in the package aquarium;

✔︎ OptionB importing by classname will take precedence over wildcards;

✔︎ OptionC importing by classname will take precedence over wildcards;

✕ OptionD Java doesn’t know which of two wildcards Water will be used;

✕ OptionE specify the same classname Water in two imports

Reference