• Home
  • Textbooks
  • Java Programming
  • Using Classes and Objects

Java Programming

Joyce Farrell

Chapter 4

Using Classes and Objects - all with Video Answers

Educators


Section 1

Review Questions

Problem 1

An object’s data items are also known as _________________.
a. fields
b. functions
c. themes
d. instances

Check back soon!

Problem 2

You send messages or information to an object through its _________________.
a. fields
b. methods
c. classes
d. type

Check back soon!

Problem 3

A program or class that instantiates objects of another prewritten class is a(n) _________________.
a. class client
b. superclass
c. object
d. patron

Check back soon!

Problem 4

The body of a class is always written _________________.
a. in a single line, as the first statement in a class
b. within parentheses
c. between curly braces
d. as a method call

Check back soon!

Problem 5

Most class data fields are _________________.
a. private
b. public
c. static
d. final

Check back soon!
00:44

Problem 6

The concept of allowing a class’s private data to be changed only by a class’s own methods is known as _________________.
a. structured logic
b. object orientation
c. information hiding
d. data masking

Aditya Sood
Aditya Sood
Numerade Educator

Problem 7

Suppose you declare an object as Book myJournal;. Before you store data in myJournal, you _________________.
a. also must explicitly allocate memory for it
b. need not explicitly allocate memory for it
c. must explicitly allocate memory for it only if it has a constructor
d. cannot explicitly declare memory for it

Check back soon!

Problem 8

If a class is named Student, the class constructor name is _________________.
a. any legal Java identifier
b. any legal Java identifier that begins with S
c. StudentConstructor()
d. Student()

Check back soon!

Problem 9

If you use the automatically supplied default constructor when you create an object, _________________.
a. int fields are set to 0 (zero)
b. char fields are set to blank
c. boolean fields are set to true
d. String fields are set to blanks

Check back soon!

Problem 10

If you declare a variable as an instance variable within a class, and you declare and use the same variable name within a method of the class, then within the method, _________________.
a. the variable used inside the method takes precedence
b. the class instance variable takes precedence
c. the two variables refer to a single memory address
d. an error will occur

Check back soon!
01:58

Problem 11

A constructor _________________ parameters.
a. can receive
b. cannot receive
c. must receive
d. can receive a maximum of 10

Crystal Wang
Crystal Wang
Numerade Educator

Problem 12

A constructor _________________ overloaded.
a. must be
b. cannot be
c. can be
d. is always automatically

Check back soon!

Problem 13

Usually, you want each instantiation of a class to have its own copy of _________________.
a. the data fields but not the methods
b. the methods but not the data fields
c. both the data fields and the methods
d. neither the data fields nor the methods

Check back soon!

Problem 14

If you create a class that contains one method, and you instantiate two objects, you usually store _________________ for use with the objects.
a. one copy of the method
b. two copies of the method
c. two different methods containing two different this references
d. data only (the methods are not stored)

Check back soon!
01:21

Problem 15

The this reference _________________.
a. can be used implicitly
b. must be used implicitly
c. must not be used implicitly
d. must not be used

Benjamin Schreyer
Benjamin Schreyer
Numerade Educator

Problem 16

Methods that you reference with individual objects are _________________.
a. private
b. public
c. static
d. nonstatic

Check back soon!

Problem 17

Variables that are shared by every instantiation of a class are _________________.
a. class variables
b. private variables
c. public variables
d. illegal

Check back soon!
00:58

Problem 18

The keyword final used with a variable declaration indicates _________________.
a. the end of the program
b. it is in a static method
c. a symbolic constant
d. that no more variables will be declared in the program

Ernest Castorena
Ernest Castorena
Numerade Educator
01:21

Problem 19

Which of the following statements determines the square root of a number and assigns it to the variable s?
a. s = sqrt(number);
b. s = Math.sqrt(number);
c. number = sqrt(s);
d. number = Math.sqrt(s);

AG
Ankit Gupta
Numerade Educator
04:45

Problem 20

Which of the following expressions correctly returns an integer that represents the month of a LocalDate object named hireDate?
a. getMonth(hireDate)
b. getMonthValue(hireDate)
c. hireDate.getMonthValue()
d. hireDate.setMonthValue()

John Bell
John Bell
Numerade Educator