Deck 3: A First Look at Classes and Objects

Full screen (f)
exit full mode
Question
"Shadowing" is the term used to describe how the field name is hidden by the name of a local or parameter variable.
Use Space or
up arrow
down arrow
to flip the card.
Question
Which symbol indicates that a member is public in a UML diagram?

A) -
B) *
C) #
D) +
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
Question
A method that stores a value in a class's field or in some other way changes the value of a field is known as a mutator method.
Question
Using the blueprint/house analogy, you can think of a class as a blueprint that describes a house and __________ as instances of the house built from the blueprint.

A) methods
B) fields
C) objects
D) attributes
Question
The java.lang package is automatically imported into all Java programs.
Question
The public access specifier for a field indicates that the field may not be accessed by statements outside 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.
Question
A group of related classes is called a(n)

A) archive
B) package
C) collection
D) attachment
Question
Class objects normally have __________ that perform useful operations on their data, but primitive variables do not.

A) fields
B) relationships
C) methods
D) instances
Question
An access specifier indicates how a class may be accessed.
Question
When an object is created, the attributes associated with the object are called

A) instance fields
B) class instances
C) instance methods
D) fixed attributes
Question
The term "default constructor" is applied to the first constructor written by the author of the class.
Question
When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable.
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
Question
A class's responsibilities include

A) the things a class is responsible for knowing
B) the things a class is responsible for doing
C) both of these
D) neither of these
Question
Methods that operate on an object's fields are called

A) instance methods
B) instance variables
C) private methods
D) public methods
Question
Another term for an object of a class is a(n)

A) access specifier
B) instance
C) member
D) method
Question
The term "no-arg constructor" is applied to any constructor that does not accept arguments.
Question
A constructor is a method that is automatically called when an object is created.
Question
Which symbol indicates that a member is private a UML diagram?

A) -
B) *
C) #
D) +
Question
One or more objects may be created from a(n)

A) field
B) method
C) instance
D) class
Question
UML diagrams do not contain

A) fields
B) methods
C) class names
D) object names
Question
To indicate the data type of a variable in a UML diagram you specify

A) the variable name followed by the data type
B) the class name followed by the variable name followed by the data type
C) the variable name followed by a colon and the data type
D) the data type followed by the variable name
Question
For the following code, which statement is not true?
public class Sphere
{
Private double radius;
Public double x;
Private double y;
Private double z;
}

A) The z field is available to code written outside the Sphere class.
B) The radius field is not available to code written outside the Sphere class.
C) The radius, x, y, and z fields are members of the Sphere class.
D) The x field is available to code that is written outside the Sphere class.
Question
Which is the key word used to import a class?

A) import
B) assume
C) use
D) link
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
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 Height that is a double data type
Question
When an argument is passed by value

A) the parameter variable holds the address of the argument
B) the parameter variable cannot be changed
C) the parameter variable holds a copy of the value passed to it
D) changes can be made to the argument variable
Question
For the following code, which statement is not true?
public class Circle
{
Private double radius;
Public double x;
Private double y;
}

A) The y field is available to code written outside the Circle class.
B) The radius field is not available to code written outside the Circle class.
C) The radius, x, and y fields are members of the Circle class.
D) The x field is available to code that is written outside the Circle class.
Question
If you do not provide initialization values for a class's numeric fields, they will

A) cause a runtime error
B) contain an unknown value
C) be automatically initialized to 0
D) cause a compiler error
Question
A constructor

A) always accepts two arguments
B) has the same name as the class
C) has the return type of void
D) always has a private access specifier
Question
Which of the following is not involved in identifying the classes to be used when developing an object-oriented application?

A) Describe the problem domain.
B) Write the code.
C) Refine the list of nouns to include only those relevant to the problem.
D) Identify all the nouns.
Question
The key word new

A) creates a new class
B) creates a new Java byte code file
C) creates an object in memory
D) creates a new variable in memory
Question
After the header, the body of the method appears inside a set of

A) braces, { }
B) parentheses, ( )
C) brackets, [ ]
D) double quotes, " "
Question
What is the following statement 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
Question
A method

A) may have zero or more parameters
B) never has parameter variables
C) must have at least two parameter variables
D) may not have only one parameter variable
Question
It is common practice in object-oriented programming to make all of a class's

A) fields private
B) methods private
C) fields public
D) fields and methods public
Question
The scope of a local variable is

A) inside the parentheses of a method header
B) the method in which it is defined
C) inside the class but not inside any method
D) the entire class
Question
What is the following statement an example of?
import java.util.Scanner;

A) an explicit import statement
B) an unconditional import statement
C) a wildcard import statement
D) a conditional import statement
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 3: A First Look at Classes and Objects
1
"Shadowing" is the term used to describe how the field name is hidden by the name of a local or parameter variable.
True
2
Which symbol indicates that a member is public in a UML diagram?

A) -
B) *
C) #
D) +
D
3
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
C
4
A method that stores a value in a class's field or in some other way changes the value of a field is known as a mutator method.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
Using the blueprint/house analogy, you can think of a class as a blueprint that describes a house and __________ as instances of the house built from the blueprint.

A) methods
B) fields
C) objects
D) attributes
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
The java.lang package is automatically imported into all Java programs.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
The public access specifier for a field indicates that the field may not be accessed by statements outside the class.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
A method that gets a value from a class's field but does not change it is known as a mutator method.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
9
A group of related classes is called a(n)

A) archive
B) package
C) collection
D) attachment
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
Class objects normally have __________ that perform useful operations on their data, but primitive variables do not.

A) fields
B) relationships
C) methods
D) instances
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
An access specifier indicates how a class may be accessed.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
When an object is created, the attributes associated with the object are called

A) instance fields
B) class instances
C) instance methods
D) fixed attributes
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
The term "default constructor" is applied to the first constructor written by the author of the class.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
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
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
A class's responsibilities include

A) the things a class is responsible for knowing
B) the things a class is responsible for doing
C) both of these
D) neither of these
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
17
Methods that operate on an object's fields are called

A) instance methods
B) instance variables
C) private methods
D) public methods
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
Another term for an object of a class is a(n)

A) access specifier
B) instance
C) member
D) method
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
19
The term "no-arg constructor" is applied to any constructor that does not accept arguments.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
A constructor is a method that is automatically called when an object is created.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
Which symbol indicates that a member is private a UML diagram?

A) -
B) *
C) #
D) +
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
One or more objects may be created from a(n)

A) field
B) method
C) instance
D) class
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
UML diagrams do not contain

A) fields
B) methods
C) class names
D) object names
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
24
To indicate the data type of a variable in a UML diagram you specify

A) the variable name followed by the data type
B) the class name followed by the variable name followed by the data type
C) the variable name followed by a colon and the data type
D) the data type followed by the variable name
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
For the following code, which statement is not true?
public class Sphere
{
Private double radius;
Public double x;
Private double y;
Private double z;
}

A) The z field is available to code written outside the Sphere class.
B) The radius field is not available to code written outside the Sphere class.
C) The radius, x, y, and z fields are members of the Sphere class.
D) The x field is available to code that is written outside the Sphere class.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
26
Which is the key word used to import a class?

A) import
B) assume
C) use
D) link
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
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
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
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 Height that is a double data type
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
29
When an argument is passed by value

A) the parameter variable holds the address of the argument
B) the parameter variable cannot be changed
C) the parameter variable holds a copy of the value passed to it
D) changes can be made to the argument variable
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
30
For the following code, which statement is not true?
public class Circle
{
Private double radius;
Public double x;
Private double y;
}

A) The y field is available to code written outside the Circle class.
B) The radius field is not available to code written outside the Circle class.
C) The radius, x, and y fields are members of the Circle class.
D) The x field is available to code that is written outside the Circle class.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
If you do not provide initialization values for a class's numeric fields, they will

A) cause a runtime error
B) contain an unknown value
C) be automatically initialized to 0
D) cause a compiler error
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
A constructor

A) always accepts two arguments
B) has the same name as the class
C) has the return type of void
D) always has a private access specifier
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following is not involved in identifying the classes to be used when developing an object-oriented application?

A) Describe the problem domain.
B) Write the code.
C) Refine the list of nouns to include only those relevant to the problem.
D) Identify all the nouns.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
The key word new

A) creates a new class
B) creates a new Java byte code file
C) creates an object in memory
D) creates a new variable in memory
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
After the header, the body of the method appears inside a set of

A) braces, { }
B) parentheses, ( )
C) brackets, [ ]
D) double quotes, " "
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
What is the following statement 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
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
A method

A) may have zero or more parameters
B) never has parameter variables
C) must have at least two parameter variables
D) may not have only one parameter variable
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
It is common practice in object-oriented programming to make all of a class's

A) fields private
B) methods private
C) fields public
D) fields and methods public
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
The scope of a local variable is

A) inside the parentheses of a method header
B) the method in which it is defined
C) inside the class but not inside any method
D) the entire class
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
40
What is the following statement an example of?
import java.util.Scanner;

A) an explicit import statement
B) an unconditional import statement
C) a wildcard import statement
D) a conditional import statement
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.