Using Java Packages - Quiz Explanation

The correct answers for the quiz are indicated below, along with text that explains the correct answers.
 
1. To import a class called Panel that's in the java.awt package, you can write
Please select the best answer.
  A. import java.awt; at the end of your source file
  B. import java.awt; at the top of your source file
  C. import java.awt.*; at the top of your source file
  D. import "java.awt.Panel"; at the top of your source file
  The correct answer is C.
You can import the Panel class from the java.awt package by writing import java.awt.Panel; or by importing all classes in a particular package, as in answer C.


2. To define a new package, you should:
Please select the best answer.
  A. Write the keyword package at the top of your source file, followed by the name of the package.
  B. Write the keyword package anywhere in your source file, followed by the name of the package.
  C. Compile your source code using the -d option found in the JDK compiler.
  D. Call tech support.
  The correct answer is A.
The package keyword must be the first thing that appears in your source file. The -d option mentioned in answer C is useful for compiling packages since it places all compiled classes into the proper directory structure automatically, but it is not how you define a new package in the first place.