Deck 4: More Object Concepts

Full screen (f)
exit full mode
Question
When you write your own constructors, you cannot write versions that receive parameters.
Use Space or
up arrow
down arrow
to flip the card.
Question
You can use the keyword final with methods or classes.
Question
If you give the same name to a class's instance field and to a local method variable, the instance variable overrides the method's local variable.
Question
As long as you do not make any ambiguous method calls, a program that contains a potentially ambiguous situation will execute correctly.
Question
Object-oriented programmers use the term ____ when a child class contains a field or method that has the same name as one in the parent class.

A) out of scope
B) ambiguous
C) override
D) parent friendly
Question
A block can exist entirely within another block or entirely outside and separate from another block, and sometimes blocks can overlap.
Question
A locally declared variable always ____ another variable with the same name elsewhere in the class.

A) creates
B) masks
C) deletes
D) uses
Question
If an integer is passed to a method with a double parameter, the double is promoted to an integer.
Question
It is illegal to declare the same variable name more than once within a block.
Question
It is a convenience to be able to use one reasonable name for ____ that are functionally identical except for argument types.

A) arguments
B) classes
C) tasks
D) packages
Question
A disadvantage of Java is the large memory requirements to store a separate copy of each variable and method for each instantiation of a class.
Question
When you properly ____ a method, you can call it providing different argument lists, and the appropriate version of the method executes.

A) declare
B) overload
C) name
D) delete
Question
Within any class or method, the code between a pair of curly braces is called a(n) ____.

A) overload
B) argument
C) scope
D) block
Question
____ involves using one term to indicate diverse meanings, or writing multiple methods with the same name but with different parameter lists.

A) Referencing
B) Overloading
C) Nesting
D) Signing
Question
When they have the same name, variables within ____ of a class override the class's fields.

A) packages
B) statements
C) fields
D) methods
Question
A variable comes into existence, or ____, when you declare it.

A) goes out of scope
B) comes into scope
C) overrides scope
D) is referenced
Question
An alternative to importing a class is to import an entire package of classes.
Question
When an application contains just one version of a method, you can call the method using a(n) ____ of the correct data type.

A) parameter
B) scope
C) output
D) constructor
Question
A method can receive ____ arguments, even if it is defined as needing double arguments.

A) string
B) integer
C) constructor
D) send
Question
When you overload a Java method, you write multiple methods with a shared name.
Question
It is not necessary to create an instance of the Math class because the constants and methods of the class are ____.

A) void
B) final
C) static
D) public
Question
When calling this() from a constructor, it must be the ____ statement within the constructor.

A) first
B) ending
C) second
D) indented
Question
When you instantiate an object from a class, ____ is reserved for each instance field in the class.

A) a constructor
B) a signature
C) memory
D) a field name
Question
____ variables are variables that are shared by every instantiation of a class.

A) Integer
B) Instance
C) Class
D) Time
Question
If a class's only constructor requires an argument, you must provide an argument for every ____ of the class that you create.

A) parameter
B) type
C) object
D) method
Question
When you ____________________ methods, you risk creating an ambiguous situation-one in which the compiler cannot determine which method to use.
Question
Another name for a nonstatic member class is a(n) ____.

A) static member class
B) inner class
C) local class
D) anonymous class
Question
When an object of one class is a data field within another class, they are related by ____.

A) extension
B) scope
C) composition
D) is-a
Question
You can use the asterisk (*) as a ____, which indicates that it can be replaced by any set of characters.

A) magic number
B) wildcard symbol
C) character symbol
D) placeholder
Question
You can use ____ arguments to initialize field values, but you can also use arguments for any other purpose.

A) object
B) constructor
C) data
D) field
Question
The compiler determines which version of a method to call by the method's ____.

A) name
B) signature
C) output
D) constructor
Question
In a Java ____________________ statement, you use a wildcard symbol to represent all the classes in a package.
Question
The keyword ____ indicates that a field value is unalterable.

A) end
B) final
C) permanent
D) static
Question
A(n) ____________________ begins immediately after the method declaration and ends at the end of the method.
Question
A(n) ____________________ is simply a folder that provides a convenient grouping for classes.
Question
Due to automatic type promotion, when a method with a double parameter is passed an integer, the integer will be promoted to a(n) ____.

A) integer
B) short
C) boolean
D) double
Question
The ____ statement notifies the program that you will be using the data and method names that are part of the imported class or package.

A) use
B) package
C) class
D) import
Question
The reference to an object that is passed to any object's nonstatic class method is called the ____.

A) magic number
B) this reference
C) literal constant
D) reference
Question
The ____ package contains frequently used classes and is implicitly imported into Java programs.

A) javax.swing
B) java.lang
C) JOptionPane
D) System
Question
When you pass a(n) ____________________, you pass a memory address.
Question
int aMethod(int x)
void aMethod(int x)
In the above statements, explain why these two methods are illegal in the class.
Question
Describe the impact that blocks and methods have on variables with the same name.
Question
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Useful when working with dates and times
Question
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Variables associated with individual objects
Question
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
An illegal action
Question
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Defines mathematical constants such as PI
Question
What are the four types of nested classes?
Question
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
No object associated with them
Question
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Created using the keyword final
Question
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
A variable comes into existence
Question
Describe and provide an example of overloading.
Question
Using an example, explain how nested blocks are created.
Question
What does a programmer need to know in order to use two variables with the same name in a class?
Question
What is a reference and what is the meaning of the keyword this?
Question
What is the difference between class variables and instance variables?
Question
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Using one term to indicate diverse meanings
Question
Describe how a programmer can make a variable in or out of scope.
Question
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Must be explicitly named in an import statement
Question
What are the three methods that enable you to incorporate prewritten classes with your programs?
Question
How does an overloaded method become ambiguous, and why might a programmer not be able to see a problem?
Question
Describe the purpose of creating and calling constructors that receive parameters. Why would you overload constructors?
Question
Explain the java.lang package and why it is important. How does this relate to the java.lang.Math class?
Question
Declare a GregorianCalendar object named year. Use the GregorianCalendar class and the get() method to display the current year in a println statement.
Question
public class StudentScores
{
private int ScoreOne;
private int ScoreTwo;
private int ScoreThree;
____
____
____
____
____
}
Using the code above, fill in the blank lines provided to create a constructor that will require parameters for the three score data fields. Be sure to include the necessary brackets and semicolons.
Question
public class StudentScores
{
private int ScoreOne;
private int ScoreTwo;
private int ScoreThree;
____
____
____
____
____
}
Suppose you want to assign all students a score of 95 on the third test. Using the code above, fill in the blank lines provided to create a two-parameter constructor that will require parameters for the first and second test score data fields, and will assign a value of 95 to the third test score data field. Be sure to include the necessary brackets and semicolons.
Question
What does it mean when a variable overrides another variable? Describe the process of declaring variables in methods and memory locations.
Question
When working with the GregorianCalendar class, what is the statement that will import the GregorianCalendar class using the full class path? Likewise, what statement will import the GregorianCalendar class and any other java.util classes?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/67
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 4: More Object Concepts
1
When you write your own constructors, you cannot write versions that receive parameters.
False
2
You can use the keyword final with methods or classes.
True
3
If you give the same name to a class's instance field and to a local method variable, the instance variable overrides the method's local variable.
False
4
As long as you do not make any ambiguous method calls, a program that contains a potentially ambiguous situation will execute correctly.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
5
Object-oriented programmers use the term ____ when a child class contains a field or method that has the same name as one in the parent class.

A) out of scope
B) ambiguous
C) override
D) parent friendly
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
6
A block can exist entirely within another block or entirely outside and separate from another block, and sometimes blocks can overlap.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
7
A locally declared variable always ____ another variable with the same name elsewhere in the class.

A) creates
B) masks
C) deletes
D) uses
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
8
If an integer is passed to a method with a double parameter, the double is promoted to an integer.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
9
It is illegal to declare the same variable name more than once within a block.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
10
It is a convenience to be able to use one reasonable name for ____ that are functionally identical except for argument types.

A) arguments
B) classes
C) tasks
D) packages
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
11
A disadvantage of Java is the large memory requirements to store a separate copy of each variable and method for each instantiation of a class.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
12
When you properly ____ a method, you can call it providing different argument lists, and the appropriate version of the method executes.

A) declare
B) overload
C) name
D) delete
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
13
Within any class or method, the code between a pair of curly braces is called a(n) ____.

A) overload
B) argument
C) scope
D) block
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
14
____ involves using one term to indicate diverse meanings, or writing multiple methods with the same name but with different parameter lists.

A) Referencing
B) Overloading
C) Nesting
D) Signing
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
15
When they have the same name, variables within ____ of a class override the class's fields.

A) packages
B) statements
C) fields
D) methods
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
16
A variable comes into existence, or ____, when you declare it.

A) goes out of scope
B) comes into scope
C) overrides scope
D) is referenced
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
17
An alternative to importing a class is to import an entire package of classes.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
18
When an application contains just one version of a method, you can call the method using a(n) ____ of the correct data type.

A) parameter
B) scope
C) output
D) constructor
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
19
A method can receive ____ arguments, even if it is defined as needing double arguments.

A) string
B) integer
C) constructor
D) send
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
20
When you overload a Java method, you write multiple methods with a shared name.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
21
It is not necessary to create an instance of the Math class because the constants and methods of the class are ____.

A) void
B) final
C) static
D) public
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
22
When calling this() from a constructor, it must be the ____ statement within the constructor.

A) first
B) ending
C) second
D) indented
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
23
When you instantiate an object from a class, ____ is reserved for each instance field in the class.

A) a constructor
B) a signature
C) memory
D) a field name
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
24
____ variables are variables that are shared by every instantiation of a class.

A) Integer
B) Instance
C) Class
D) Time
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
25
If a class's only constructor requires an argument, you must provide an argument for every ____ of the class that you create.

A) parameter
B) type
C) object
D) method
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
26
When you ____________________ methods, you risk creating an ambiguous situation-one in which the compiler cannot determine which method to use.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
27
Another name for a nonstatic member class is a(n) ____.

A) static member class
B) inner class
C) local class
D) anonymous class
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
28
When an object of one class is a data field within another class, they are related by ____.

A) extension
B) scope
C) composition
D) is-a
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
29
You can use the asterisk (*) as a ____, which indicates that it can be replaced by any set of characters.

A) magic number
B) wildcard symbol
C) character symbol
D) placeholder
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
30
You can use ____ arguments to initialize field values, but you can also use arguments for any other purpose.

A) object
B) constructor
C) data
D) field
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
31
The compiler determines which version of a method to call by the method's ____.

A) name
B) signature
C) output
D) constructor
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
32
In a Java ____________________ statement, you use a wildcard symbol to represent all the classes in a package.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
33
The keyword ____ indicates that a field value is unalterable.

A) end
B) final
C) permanent
D) static
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
34
A(n) ____________________ begins immediately after the method declaration and ends at the end of the method.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
35
A(n) ____________________ is simply a folder that provides a convenient grouping for classes.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
36
Due to automatic type promotion, when a method with a double parameter is passed an integer, the integer will be promoted to a(n) ____.

A) integer
B) short
C) boolean
D) double
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
37
The ____ statement notifies the program that you will be using the data and method names that are part of the imported class or package.

A) use
B) package
C) class
D) import
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
38
The reference to an object that is passed to any object's nonstatic class method is called the ____.

A) magic number
B) this reference
C) literal constant
D) reference
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
39
The ____ package contains frequently used classes and is implicitly imported into Java programs.

A) javax.swing
B) java.lang
C) JOptionPane
D) System
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
40
When you pass a(n) ____________________, you pass a memory address.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
41
int aMethod(int x)
void aMethod(int x)
In the above statements, explain why these two methods are illegal in the class.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
42
Describe the impact that blocks and methods have on variables with the same name.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
43
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Useful when working with dates and times
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
44
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Variables associated with individual objects
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
45
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
An illegal action
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
46
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Defines mathematical constants such as PI
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
47
What are the four types of nested classes?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
48
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
No object associated with them
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
49
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Created using the keyword final
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
50
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
A variable comes into existence
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
51
Describe and provide an example of overloading.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
52
Using an example, explain how nested blocks are created.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
53
What does a programmer need to know in order to use two variables with the same name in a class?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
54
What is a reference and what is the meaning of the keyword this?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
55
What is the difference between class variables and instance variables?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
56
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Using one term to indicate diverse meanings
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
57
Describe how a programmer can make a variable in or out of scope.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
58
Match each term with the correct statement below.
a.optional classes
f.Math class
b.instance variables
g.redeclaring a variable
c.comes into scope
h.GregorianCalendar
d.class methods
i.constant
e.overloading
Must be explicitly named in an import statement
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
59
What are the three methods that enable you to incorporate prewritten classes with your programs?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
60
How does an overloaded method become ambiguous, and why might a programmer not be able to see a problem?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
61
Describe the purpose of creating and calling constructors that receive parameters. Why would you overload constructors?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
62
Explain the java.lang package and why it is important. How does this relate to the java.lang.Math class?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
63
Declare a GregorianCalendar object named year. Use the GregorianCalendar class and the get() method to display the current year in a println statement.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
64
public class StudentScores
{
private int ScoreOne;
private int ScoreTwo;
private int ScoreThree;
____
____
____
____
____
}
Using the code above, fill in the blank lines provided to create a constructor that will require parameters for the three score data fields. Be sure to include the necessary brackets and semicolons.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
65
public class StudentScores
{
private int ScoreOne;
private int ScoreTwo;
private int ScoreThree;
____
____
____
____
____
}
Suppose you want to assign all students a score of 95 on the third test. Using the code above, fill in the blank lines provided to create a two-parameter constructor that will require parameters for the first and second test score data fields, and will assign a value of 95 to the third test score data field. Be sure to include the necessary brackets and semicolons.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
66
What does it mean when a variable overrides another variable? Describe the process of declaring variables in methods and memory locations.
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
67
When working with the GregorianCalendar class, what is the statement that will import the GregorianCalendar class using the full class path? Likewise, what statement will import the GregorianCalendar class and any other java.util classes?
Unlock Deck
Unlock for access to all 67 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 67 flashcards in this deck.