Chapter 6 A First Look at Classes (Review Questions and Exercise)

¡Supera tus tareas y exámenes ahora con Quizwiz!

The constructor that Java provides is known as the default constructor. It sets all of the object's numeric fields to ______.

0

______ are used to perform operations at the time an object is created.

Constructors

________ typically initialize instance fields and perform other object initialization tasks.

Constructors

True or False: A class may not have more than one constructor.

False

True or False: When you write a constructor for a class, it still has the default constructor that Java automatically provides.

False (Java will only provide a constructor if you don't write one)

True or False: To find the classes needed for an object-oriented application, you identify all of the verbs in a description of the problem domain.

False (You identify all of the nouns)

Objects have two general capabilities:

Objects can store data and can perform operations

True or False: Each instance of a class has its own set of instance fields.

True

True or False: The new operator creates an instance of a class.

True

___ _____ ____ provides a set of standard diagrams for graphically depicting object oriented systems.

Unified Modeling Language (UML)

An _____ ______ is a Java keyword that indicates how a field or method can be accessed.

access specifier

Each field that the programmer wishes to be viewed by other classes needs an _______.

accessor

This is a method that gets a value from a class's field, but does not change it.

accessor

The methods that retrieve the data of fields are called______.

accessors

When an object is created, its constructor is ___ ______.

always called

When using a constructor that has parameter variables, you must provide _______ for them.

arguments

A class's responsibilities are __________.

b. things the class knows c. actions the class performs

The process of matching a method call with the correct method is known as ______ .

binding

The process of matching a method call with the correct method is known as __________.

binding

A class is analogous to a(n) ______.

blueprint

You can think of a class as a code "______" that can be used to create a particular type of object.

blueprint

A _____ is code that describes a particular type of object. It specifies the data that an object can hold (the object's fields), and the actions that an object can perform (the object's methods).

class

Explicit imports name a specific ____

class

This is a collection of programming statements that specify the fields and methods that a particular type of object may have.

class

A _______ is a method that is automaticcally called when an object is created.

constructor

This is a method that is automatically called when an instance of a class is created.

constructor

Objects created from a class each have their own ______ of instance fields.

copy

Instance fields and instance methods require an object to be _______ in order to be used.

created

If you do not write a constructor, Java provides one when the class is compiled. The constructor that Java provides is known as the _____ _____

default constructor

This is automatically provided for a class if you do not write one yourself.

default constructor

The only time that Java provides a default constructor is when you ____ _____ write constructor for a class.

do not

If an instance field is declared with the public access specifier, it can also be accessed by code outside the class, as long as an instance of the class ______.

exists

The constructor that Java provides is known as the default constructor. It sets all of the object's boolean fields to ______.

false

This is a class member that holds data.

field

Objects can store data. The pieces of data stored in an object are known as _____ .

fields

Other names for accessor and mutator methods are ______ ____ _____

getters and setters

Reference variables can be declared without being _____.

initialized

Each object that is created from a class is called an ______ of the class.

instance

An object is a(n) __________.

instance of a class

Data hiding helps enforce the ______of an object's internal data.

integrity

The ___ ___ package is automatically made available to any Java class.

java.lang

When you pass a object as an argument, the thing that is passed into the parameter variable is the object's ____ _______.

memory address

Objects can perform operations. The operations that an object can perform are known as ____ .

methods

Only the class's ______ may directly access and make changes to the object's internal data.

methods

Each field that the programmer wishes to be modified by other classes needs a _______.

mutator

The methods that modify the data of fields are called _______.

mutator

This is a method that stores a value in a field or in some other way changes the value

mutator

Constructors have the same _____ as the class.

name

Declaring a variable to reference an object does not create an object. You must use the ____ key word to create the object.

new

This key word causes an object to be created in memory.

new

A constructor that does not accept arguments is known as a ___ ___ constructor .

no-arg

If you write a constructor that accepts arguments, you must also write a ___ ____ constructor for the same class if you want to be able to create instances of the class without passing arguments to the constructor.

no-arg

The default constructor (provided by Java) is a __ ___ constructor.

no-arg

A default constructor is _____ provided by Java if a constructor is already written.

not

The constructor that Java provides is known as the default constructor. It sets all of the object's reference variables to the special value _______ .

null

Wildcard imports name a _____, followed by an *

package

Overloaded methods must have unique _______ lists.

parameter

Two or more methods in a class may have the same name as long as their ____ lists are different. When this occurs, it is called overloading method. This also applies to constructors.

parameter

The default constructor is a constructor with no______, used to initialize an object in a default configuration.

parameters

The name of a class appears after the new key word, and a set of parentheses appears after the class name. You must write the _____ even if no arguments are passed to the constructor.

parentheses

Because of the concept of data hiding, fields in a class are ________.

private

When the _______ access specifier is applied to a class member, the member cannot be accessed by code outside the class. The member can be accessed only by methods that are members of the same class.

private

Constructors are typically _____.

public

When the ______ access specifier is applied to a class member, the member can be accessed by code inside the class or outside.

public

Code outside the class must use the class's____ ______ to operate on an object's private fields.

public methods

A local reference variable must ______ an object before it can be used, otherwise a compiler error will occur.

reference

Constructors have no _____ type (not even Constructors may not return any values. Constructors are typically public. void ).

return

Constructors may not _____ any values.

return

Variables declared as instance fields in a class can be accessed by any instance method in the _____ ____ as the field.

same class

A _______ never appears at the end of a method header.

semicolon

A method may have a local variable with the same name as an instance field. This is called _____

shadowing

When a local variable has the same name as a field, the local variable's name does this to the field's name.

shadows

When a method's local variable has the same name as a field in the same class, the local variable's name _____the field's name.

shadows

A method ______ consists of the method's name and the data types of the method's parameters, in the order that they appear.

signature

The compiler uses the method ______ to determine which version of the overloaded method to bind the call to

signature

To avoid _____ data, it is best to calculate the value of that data within a method rather than store it in a variable.

stale

When the value of an item is dependent on other data, and that item is not updated when the other data is changed, what has the value become?

stale

Instance methods are methods that are declared with a special keyword, not _____ .

static

Two or more methods in a class may have the same name, as long as this is different.

their parameter lists


Conjuntos de estudio relacionados

Real Estate Settlement Procedures Act (RESPA)

View Set

Environmental Health & Science Final Study Guide

View Set

Project Initiation: Starting a Successful Project | Week 2

View Set

Post Test: A Nation Reforms (1877-1914)

View Set

Chapter 1 - Limits, Alternatives, and Choices

View Set

Chpt 8: Inchoate Crimes- Attempt, Conspiracy, and Solicitation

View Set

ML_Model Selection and Regularization

View Set