Chapter 6

25 July 2022
4.7 (114 reviews)
43 test answers

Unlock all answers in this set

Unlock answers (39)
question
The term "no-arg constructor" is applied to any constructor that does not accept arguments T or F
answer
T
question
Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable. T or F
answer
T
question
Instance methods do not have the key word static in their headers. T or F
answer
T
question
When an object is created, the attributes associated with the object are called __________.
answer
Instance fields
question
Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by __________. a. using the public access specifier on the class methods b. using the private access specifier on the class methods c. using the private access specifier on the class fields d. using the private access specifier on the class definition
answer
C. using the private access specifier on the class fields
question
Methods that operate on an object's fields are called __________. a. instance methods c. private methods b. instance variables d. public methods
answer
A. Instance methods
question
A group of related classes is called a(n) __________. a. archive c. collection b. package d. attachment
answer
A. archive
question
Class objects normally have __________ that perform useful operations on their data, but primitive variables do not. a. fields c. methods b. relationships d. instances
answer
C. methods
question
You should not define a class that is dependent on the values of other class fields __________. a. in order to keep it current b. because it is redundant c. in order to avoid having stale data d. because it should be defined in another class
answer
C. in order to avoid having stale data
question
Another term for an object of a class is a(n) __________. a. access specifier c. member b. instance d. method
answer
B. instance
question
A class specifies the __________ and __________ that a particular type of object has. a. relationships, methods c. fields, methods b. fields, object names d. relationships, object names
answer
C. Fields, Methods
question
The scope of a private instance field is __________. a. the instance methods of the same class b. inside the class but not inside any method in that class c. inside the parentheses of a method header d. the method in which it is defined
answer
A. The instance methods of the class
question
A method that gets a value from a class's field but does not change it is known as a mutator method. TRUE FALSE
answer
True
question
A method that gets a value from a class's field but does not change it is known as a mutator method. TRUE FALSE
answer
False
question
The public access specifier for a field indicates that the field may not be accessed by statements outside the class. TRUE FALSE
answer
False
question
A constructor is a method that is automatically called when an object is created. TRUE FALSE
answer
True
question
Instance methods should be declared static. TRUE FALSE
answer
False
question
Instance methods do not have the key word static in their headers. TRUE FALSE
answer
True
question
When an object is passed as an argument to a method, the object's address is passed into the method's parameter variable. TRUE FALSE
answer
True
question
Which symbol indicates that a member is public in a UML diagram? a. - b. * c. # d. +
answer
A. +
question
Which symbol indicates that a member is private a UML diagram? a. - b. * c. # d. +
answer
D. -
question
What does the following UML diagram entry mean? + setHeight(h : double) : void a. a public method with a parameter of data type double that does not return a value b. a private field called setHeight that is a double data type c. a private method with no parameters that returns a double data type d. a public field called setHeight that is a double data type
answer
A. a public method with a parameter of data type double that does not return a value
question
Which of the following is not involved in identifying the classes to be used when developing an object-oriented application? a. a description of the problem domain b. the code c. a refined list of nouns that include only those relevant to the problem d. all the nouns are identified
answer
B. the code
question
A constructor is a method that __________. a. returns an object of the class b. never receives any arguments c. performs initialization or setup operations d. removes the object from memory
answer
C. performs initialization or setup operations
question
It is common practice in object-oriented programming to make all of a class's __________. a. fields private c. fields public b. methods private d. fields and methods public
answer
A> fiel
question
The following statement is an example of __________. import java.util.*; a. an explicit import statement b. an unconditional import statement c. a wildcard import statement d. a conditional import statement
answer
A. an explicit import statement
question
After the header, the body of the method appears inside a set of __________. a. braces, { } c. brackets, [ ] b. parentheses, ( ) d. double quotes, " "
answer
A. braces { }
question
One or more objects may be created from a(n) __________. a. field b. method c. instance d. class
answer
D. class
question
A constructor __________. a. always accepts two arguments c. has the return type of void b. has the same name as the class d. always has a private access specifier
answer
B. has the same name as the class
question
The scope of a private instance field is __________. a. the instance methods of the same class b. inside the class but not inside any method in that class c. inside the parentheses of a method header d. the method in which it is defined
answer
a. the instance methods of the same class
question
To indicate the data type of a variable in a UML diagram, you enter __________. a. the variable name followed by the data type b. the variable name followed by a colon and the data type c. the class name followed by the variable name followed by the data type d. the data type followed by the variable name
answer
B.
question
Two or more methods in a class may have the same name as long as __________. a. they have different return types b. they have different parameter lists c. they have different return types but the same parameter list d. You cannot have two methods with the same name.
answer
B
question
The scope of a public instance field is __________. a. only the class in which it is defined b. inside the class but not inside any method c. inside the parentheses of a method header d. the instance methods and methods outside the class
answer
D.
question
Overloading means that multiple methods in the same class __________. a. have the same name but different return types b. have different names but the same parameter list c. have the same name but different parameter lists d. perform the same function
answer
C.
question
When an object is passed as an argument to a method, what is passed into the method's parameter variable? a. the class name c. the values for each field b. the object's memory address d. the method names
answer
B>
question
A(n) __________ can be thought of as a blueprint that can be used to create a type of __________. a. object, class c. cookie, cake b. class, object d. object, method
answer
B
question
When you work with a __________, you are using a storage location that holds a piece of data. a. primitive variable c. numeric literal b. reference variable d. binary number
answer
A.
question
A reference variable stores a(n) __________. a. binary encoded decimal c. object b. memory address d. string
answer
B.
question
A UML diagram does not contain __________. a. the class name c. the field names b. the method names d. the object names
answer
D
question
Methods that operate on an object's fields are called __________. a. instance variables c. public methods b. instance methods d. private methods
answer
B.
question
Java allows you to create objects of the __________ class in the same way you would create primitive variables. a. Random c. PrintWriter b. String d. Scanner
answer
B. string
question
Instance methods do not have the __________ key word in their headers. a. public b. static c. private d. protected
answer
B. static
question
The __________ package is automatically imported into all Java programs. a. java.java c. java.util b. java.default d. java.lang
answer
D