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
String class static method ______________ is similar to method System.out.printf, but return a formatted String rather than displaying a String in a command window.
format
A method contains a local variable with the same name as one of it’s class fields, t he local variable is said to _______ the scope of the method’s scope.
Shadow
The public methods of a class are known as
Public Interfaces or Public Services
A(n) ________________ method is called implicitly when the objects appears in code where String is needed
ToString();
A(n) _______________ declaration specifies one class to import.
single-type-import
If a class declares constructors, the complier will not create a(n) ___________________
default constructor
Get methods are commonly called
accessors methods or query methods
If a class declares a constructor the complier will not create
a default constructor
A ____________ method tests whether a condition is true or false
predicate