Java Classes - Quiz Explanation
The correct answers are indicated below, along with text that explains the correct answers.
1.
What keyword do you use to import a class or a package containing classes?
Please select the best answer.
A.
include
B.
import
C.
package
The correct answer is B.
The
import
keyword is used to import a class or a package containing classes. There is no
include
keyword in Java. The
package
keyword is used to identify the package to which a class belongs.
2.
What standard Java package is automatically imported into every Java program?
Please select the best answer.
A.
java.applet
B.
java.lang
C.
java.io
The correct answer is B.
The standard
java.lang
package is automatically imported into every Java program. The
java.applet
and
java.io
packages must always be explicitly imported into Java programs when their functionality is required.
3.
Where must you place the
package
statement in order to identify the package to which a class belongs?
Please select the best answer.
A.
At the beginning of the source code file for the class
B.
At the end of the source code file for the class
C.
Anywhere in the source code file for the class
The correct answer is A.
The
package
statement must be placed at the beginning of the source code file for a class in order to identify the package to which the class belongs.