Chapter 8 Quiz Flashcards Preview

COP_3252 > Chapter 8 Quiz > Flashcards

Flashcards in Chapter 8 Quiz Deck (24):
1

When should a program explicitly use the this reference?

Accessing a field that is shadowed by a local variable

2

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

3

The import declaration import *; ________.

causes a compilation error

4

When no access modifier is specified for a method or variable, the method or variable:

can be accessed by any program in its package

5

A class within a package must be declared public if

It will be used by classes that are not in the same package

6

T or F
A package is a group of nested classes and interfaces

True

7

T or F
A package is a directory structure used to organize classes and interfaces.

True

8

T or F
Packages make it more difficult to reuse code

False

9

T or F
The garbage collector reclaims unused memory

True

10

T or F
The method finalize takes parameters

False

11

T or F
The method finalize uses a return type of void

True

12

What does the this method do

It allows an object to reference itself

13

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.

14

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.

15

Imports all static members of a class

static import on demand

16

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

17

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

18

The public methods of a class are known as

Public Interfaces or Public Services

19

A(n) ________________ method is called implicitly when the objects appears in code where String is needed

ToString();

20

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

single-type-import

21

If a class declares constructors, the complier will not create a(n) ___________________

default constructor

22

Get methods are commonly called

accessors methods or query methods

23

If a class declares a constructor the complier will not create

a default constructor

24

A ____________ method tests whether a condition is true or false

predicate