Chapter 8 Quiz Flashcards
When should a program explicitly use the this reference?
Accessing a field that is shadowed by a local variable
A static class variables:
are public
are private
are shared by all objects of a class
cannot be accessed by any instance of the class
are shared by all objects of a class
The import declaration import *; ________.
causes a compilation error
When no access modifier is specified for a method or variable, the method or variable:
can be accessed by any program in its package
A class within a package must be declared public if
It will be used by classes that are not in the same package
T or F
A package is a group of nested classes and interfaces
True
T or F
A package is a directory structure used to organize classes and interfaces.
True
T or F
Packages make it more difficult to reuse code
False
T or F
The garbage collector reclaims unused memory
True
T or F
The method finalize takes parameters
False
T or F
The method finalize uses a return type of void
True
What does the this method do
It allows an object to reference itself
In a class definition should a default constructor be declared private? Why or Why not?
A constructor should never be a private method as it would prevent the object from being instantiated.
What does declaring an instance variable final do?
Declaring an instance variable final means that the variable has a constant value that cannot be modified.
Imports all static members of a class
static import on demand