Packages Interfaces - Quiz Explanation

The correct answers are indicated below, along with text that explains the correct answers.
 
1. How do you import all of the classes in a package with a single statement?
Please select the best answer.
  A. Provide the package name and the * wildcard
  B. Provide only the package name
  C. Provide the name of any class in the package
  The correct answer is A.
You import all of the classes in a package by providing the package name and the * wildcard. You can not import classes by providing only a package name. Providing the name of a class within a package only results in that class being imported.


2. Which one of the following access modifiers indicates that classes, member variables, and methods are freely accessible?
Please select the best answer.
  A. private
  B. protected
  C. public
  The correct answer is C.
The public access modifier indicates that classes, member variables, and methods are freely accessible. The private access modifier indicates that member variables and methods are only accessible within the class in which they are defined. The protected access modifier indicates that member variables and methods can only be accessed by derived classes and classes in the same package as the class.

3. What is the accessibility of a class modifier if you do not explicitly declare an access modifier?
Please select the best answer.
  A. The public access modifier is assumed
  B. The default access modifier is implicitly used
  C. The access is undefined
  The correct answer is B.
If you do not explicitly declare an access modifier for a class member, the default access modifier is implicitly used. You must always explicitly use the public access modifier for it to apply. There is never a situation where the access for a class member is undefined.


4. When a class implements an interface, it is required to provide:
Please select the best answer.
  A. An implementation of each method declared in the interface
  B. An implementation of at least one method declared in the interface
  C. A default constructor
  The correct answer is A.
When a class implements an interface, it is required to provide an implementation of each method declared in the interface, not just one of the methods. The default constructor for a class has no bearing on the class implementing an interface.