Deck 3: A First Look at Classes and Objects

Full screen (f)
exit full mode
Question
Methods that operate on an object's fields are called

A) instance methods.
B) instance variables.
C) private methods.
D) public methods.
Use Space or
up arrow
down arrow
to flip the card.
Question
You should not define a class field that is dependent upon 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
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 that is 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
You use this key word to import a class.

A) import
B) assume
C) use
D) link
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
The scope of a local variable is

A) inside the parentheses of a method header.
B) the method in which they are defined.
C) inside the class, but not inside any method.
D) the entire class.
Question
Another term for an object of a class is a(n)

A) access specifier.
B) instance.
C) member.
D) method.
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
A group of related classes is called a(n)

A) archive.
B) package.
C) collection.
D) attachment.
Question
UML diagrams do not contain

A) fields.
B) methods.
C) class names.
D) object names.
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 A and B
D) neither A nor B
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
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
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 method

A) may have zero or more parameter variables.
B) never has parameter variables.
C) must have at least two parameter variables.
D) may have only one parameter variables.
Question
Which of the following is not involved in finding the classes 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 that are relevant to the problem.
D) Identify all the nouns.
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 Height 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
In the blueprint/house analogy, 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
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
In UML diagrams, what symbol indicates that a member is public?

A) -
B) *
C) #
D) +
Question
The public access specifier for a field indicates that the field may not be accessed by statements outside the class.
Question
The java.lang package is automatically imported into all Java programs.
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
A method that gets a value from a class's field but does not change it is known as a mutator method.
Question
The term "default constructor" is applied to the first constructor written by the author of the class.
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
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
When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable.
Question
A method that stores a value in a class's field or in some other way changed the value of a field is known as a mutator method.
Question
A constructor

A) always accepts two arguments.
B) has the same name as the class.
C) has return type of void.
D) always has an access specifier of private.
Question
An access specifier indicates how the class may be accessed.
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 with 0.
D) cause a compiler error.
Question
A UML diagram uses the ________ symbol to indicate that a member is private.

A) *
B) -
C) #
D) +
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 that is 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
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
Question
One or more objects may be created from a(n)

A) field.
B) method.
C) instance.
D) class.
Question
Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable.
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
After the header, the body of the method appears inside a set of

A) braces, {}.
B) parentheses, ().
C) brackets, [].
D) double quotes, "" .
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
Methods that operate on an object's fields are called

A) instance methods.
B) instance variables.
C) private methods.
D) public methods.
A
2
You should not define a class field that is dependent upon 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
3
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 that is 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.
A
4
You use this key word 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
5
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
6
The scope of a local variable is

A) inside the parentheses of a method header.
B) the method in which they are 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
7
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
8
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
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
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
11
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 A and B
D) neither A nor B
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
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
14
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
15
A method

A) may have zero or more parameter variables.
B) never has parameter variables.
C) must have at least two parameter variables.
D) may have only one parameter variables.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following is not involved in finding the classes 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 that are 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
17
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 Height 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
18
In the blueprint/house analogy, 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
19
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
20
In UML diagrams, what symbol indicates that a member is public?

A) -
B) *
C) #
D) +
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
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
22
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
23
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
24
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
25
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
26
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
27
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
28
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
29
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
30
A method that stores a value in a class's field or in some other way changed 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
31
A constructor

A) always accepts two arguments.
B) has the same name as the class.
C) has return type of void.
D) always has an access specifier of private.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
An access specifier indicates how the class may be accessed.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
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 with 0.
D) cause a compiler error.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
A UML diagram uses the ________ symbol to indicate that a member is private.

A) *
B) -
C) #
D) +
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
35
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 that is 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
36
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
37
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
38
Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
39
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
40
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
locked card icon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.