Week 10 Test Review Flashcards

1
Q

When compiling a class in a package, the javac command-line option _____ specifies where to store the package and causes the compiler to create the package’s directories if they do not exist.

A

-d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

String class static method ______ is similar to method System.out.printf, but returns a formatted String rather than displaying a String in a command window.

A

format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If a method contains a local variable ______ iwth the same name as one of its class’s fields, the local variable the field in that method’s scope.

A

shadows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The _____ method is called by the garbage collector just before it reclaims an object’s memory.

A

finalize

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A(n) _____ declaration specifies one class to import.

A

single - type - import

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If a class declares constructors, the compiler will not create a(n) ______.

A

default constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

An object’s _______ method is called implicitly when an object appears in code where a String is needed.

A

toString

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Get methods are commonly called ______.

A

accessor methods, getters, query methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A(n) _____ method tests whether a condition is true or false.

A

predicate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

For every enum, the compiler generates a static method called _____ that returns an array of the enum’s constants in the order in which they were declared.

A

values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Composition is sometimes referred to as a(n) _____ relationship.

A

has-a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A(n) _____ variable represents classwide information that is shared by all the objects of the class.

A

static

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Keyword ______ specifies that a variable is not modifiable.

A

final

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

There can be only one _____ in a Java source-code file, and it must precede all other declarations and statements in the file.

A

package declaration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A(n) _____ declaration imports only the classes that the program uses from a particular package.

A

type-import-on-demand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly