Deck 4: More Object Concepts

Full screen (f)
exit full mode
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.
Use Space or
up arrow
down arrow
to flip the card.
Question
When you multiply an int and a double , the result is the int .
Question
You can overload methods correctly by providing different parameter lists for methods with the same name.
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
When you overload a Java method, you write multiple methods with a shared name.
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 locally declared variable always ____ another variable with the same name elsewhere in the class.

A) creates
B) masks
C) deletes
D) uses
Question
An alternative to importing a class is to import an entire package of classes.
Question
A block can exist entirely within another block or entirely outside and separate from another block, and sometimes blocks can overlap.
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
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
When you write your own constructors, you cannot write versions that receive parameters.
Question
A method can receive ____ arguments, even if it is defined as needing double arguments.

A) string
B) integer
C) constructor
D) send
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 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
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
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
It is illegal to declare the same variable name more than once within a block.
Question
Fields declared to be static are not always final .
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
The ____ package contains is implicitly imported into Java programs and is the only automatically imported, named package.

A) javax.swing
B) java.lang
C) JOptionPane
D) System
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
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
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
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
In a Java ____________________ statement, you use a wildcard symbol to represent all the classes in a package.
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
The compiler determines which version of a method to call by the method's ____.

A) name
B) signature
C) output
D) constructor
Question
When you ____________________ methods, you risk creating an ambiguous situation-one in which the compiler cannot determine which method to use.
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
A(n) ____________________ begins immediately after the method declaration and ends at the end of the method.
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
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
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 calling this() from a constructor, it must be the ____ statement within the constructor.

A) first
B) ending
C) second
D) indented
Question
____ variables are variables that are shared by every instantiation of a class.

A) Integer
B) Instance
C) Class
D) Time
Question
When you pass a(n) ____________________, you pass a memory address.
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
A(n) ____________________ is simply a folder that provides a convenient grouping for classes.
Question
If you want all objects to share a single nonchanging value, then the field is static and ______.

A) end
B) final
C) permanent
D) class
Question
Match between columns
Premises:
Responses:
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
Question
List the three things you can do that allow you to use prewritten classes.
Question
 Using Java statements, show how you can use the LocalDate class by using the full path and by using an import statement.
Question
int aMethod(int x)
void aMethod(int x)
In the above statements, explain why these two methods are illegal in the class.
Question
  Explain why it is a problem that the highlighted statements are local variables. How could you fix this problem?<div style=padding-top: 35px>
Explain why it is a problem that the highlighted statements are local variables. How could you fix this problem?
Question
  In the above code, what happens to the value of aNumber when the main() method is executed? What happens to the value of aNumber when the firstMethod and secondMethod methods are executed?<div style=padding-top: 35px>
In the above code, what happens to the value of aNumber when the main() method is executed? What happens to the value of aNumber when the firstMethod and secondMethod methods are executed?
Question
Explain the java.lang package and why it is important. 
Question
Write Java statements that use the now() and of() methods in the LocalDate class.
Question
What is overloading a method? What conditions must be satisfied in the parameter lists of an overloaded method?
Question
What is the difference between class variables and instance variables?
Question
List and describe the four types of nested classes.
Question
  The Student class above will allow Student information to be constructed in various ways, but is repetitive. How could you use the this reference to reduce the amount of repetitious code and make it less error-prone?<div style=padding-top: 35px> The Student class above will allow Student information to be constructed in various ways, but is repetitive. How could you use the this reference to reduce the amount of repetitious code and make it less error-prone?
Question
Describe the impact that blocks and methods have on variables with the same name.
Question
What does a programmer need to know in order to use two variables with the same name in a class?
Question
  Explain why the highlighted statements will result in an illegal action.<div style=padding-top: 35px>
Explain why the highlighted statements will result in an illegal action.
Question
Describe how a Java variable comes into and out of scope.
Question
What does it mean when a variable overrides another variable? 
Question
What is automatic type promotion in method calls? Give an example of how this works.
Question
Describe a block and define an outer block and an inner block.
Question
What is a reference and what is the meaning of the keyword this ?
Question
  In the above code, if the simpleMethod() method received a double or integer value, the resulting output is Method receives double parameter. Explain how Java can promote one data type to another when a parameter is passed to a method.<div style=padding-top: 35px>
In the above code, if the simpleMethod() method received a double or integer value, the resulting output is "Method receives double parameter". Explain how Java can promote one data type to another when a parameter is passed to a method.
Question
What is the phenomenon called shadowing?
Question
  Explain and describe the this reference. How is the this reference used in each of the above methods?<div style=padding-top: 35px>
Explain and describe the this reference. How is the this reference used in each of the above methods?
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
  In the above code, what would happen if calculateInterest was passed the values of 100 for the bal and .10 for the interest rate? What would happen if calculateInterest was passed the values of 100 for the bal and 10 for the interest rate? Why is it a problem when these values are passed to the calculateInterest method, and what would be a possible solution to fix the problem?<div style=padding-top: 35px>
In the above code, what would happen if calculateInterest was passed the values of 100 for the bal and .10 for the interest rate? What would happen if calculateInterest was passed the values of 100 for the bal and 10 for the interest rate? Why is it a problem when these values are passed to the calculateInterest method, and what would be a possible solution to fix the problem?
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/66
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 4: More Object Concepts
1
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.
False
2
When you multiply an int and a double , the result is the int .
False
3
You can overload methods correctly by providing different parameter lists for methods with the same name.
True
4
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 66 flashcards in this deck.
Unlock Deck
k this deck
5
When you overload a Java method, you write multiple methods with a shared name.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
6
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 66 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 66 flashcards in this deck.
Unlock Deck
k this deck
8
An alternative to importing a class is to import an entire package of classes.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
9
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 66 flashcards in this deck.
Unlock Deck
k this deck
10
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.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
11
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 66 flashcards in this deck.
Unlock Deck
k this deck
12
When you write your own constructors, you cannot write versions that receive parameters.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
13
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 66 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 66 flashcards in this deck.
Unlock Deck
k this deck
15
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 66 flashcards in this deck.
Unlock Deck
k this deck
16
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 66 flashcards in this deck.
Unlock Deck
k this deck
17
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 66 flashcards in this deck.
Unlock Deck
k this deck
18
It is illegal to declare the same variable name more than once within a block.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
19
Fields declared to be static are not always final .
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
20
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 66 flashcards in this deck.
Unlock Deck
k this deck
21
The ____ package contains is implicitly imported into Java programs and is the only automatically imported, named package.

A) javax.swing
B) java.lang
C) JOptionPane
D) System
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
22
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 66 flashcards in this deck.
Unlock Deck
k this deck
23
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 66 flashcards in this deck.
Unlock Deck
k this deck
24
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 66 flashcards in this deck.
Unlock Deck
k this deck
25
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 66 flashcards in this deck.
Unlock Deck
k this deck
26
In a Java ____________________ statement, you use a wildcard symbol to represent all the classes in a package.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
27
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 66 flashcards in this deck.
Unlock Deck
k this deck
28
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 66 flashcards in this deck.
Unlock Deck
k this deck
29
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 66 flashcards in this deck.
Unlock Deck
k this deck
30
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 66 flashcards in this deck.
Unlock Deck
k this deck
31
A(n) ____________________ begins immediately after the method declaration and ends at the end of the method.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
32
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 66 flashcards in this deck.
Unlock Deck
k this deck
33
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 66 flashcards in this deck.
Unlock Deck
k this deck
34
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 66 flashcards in this deck.
Unlock Deck
k this deck
35
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 66 flashcards in this deck.
Unlock Deck
k this deck
36
____ 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 66 flashcards in this deck.
Unlock Deck
k this deck
37
When you pass a(n) ____________________, you pass a memory address.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
38
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 66 flashcards in this deck.
Unlock Deck
k this deck
39
A(n) ____________________ is simply a folder that provides a convenient grouping for classes.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
40
If you want all objects to share a single nonchanging value, then the field is static and ______.

A) end
B) final
C) permanent
D) class
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
41
Match between columns
Premises:
Responses:
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
comes into scope
composition
overloading
inner block
class methods
constant
optional classes
Math class
Java.time
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
42
List the three things you can do that allow you to use prewritten classes.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
43
 Using Java statements, show how you can use the LocalDate class by using the full path and by using an import statement.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
44
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 66 flashcards in this deck.
Unlock Deck
k this deck
45
  Explain why it is a problem that the highlighted statements are local variables. How could you fix this problem?
Explain why it is a problem that the highlighted statements are local variables. How could you fix this problem?
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
46
  In the above code, what happens to the value of aNumber when the main() method is executed? What happens to the value of aNumber when the firstMethod and secondMethod methods are executed?
In the above code, what happens to the value of aNumber when the main() method is executed? What happens to the value of aNumber when the firstMethod and secondMethod methods are executed?
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
47
Explain the java.lang package and why it is important. 
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
48
Write Java statements that use the now() and of() methods in the LocalDate class.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
49
What is overloading a method? What conditions must be satisfied in the parameter lists of an overloaded method?
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
50
What is the difference between class variables and instance variables?
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
51
List and describe the four types of nested classes.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
52
  The Student class above will allow Student information to be constructed in various ways, but is repetitive. How could you use the this reference to reduce the amount of repetitious code and make it less error-prone? The Student class above will allow Student information to be constructed in various ways, but is repetitive. How could you use the this reference to reduce the amount of repetitious code and make it less error-prone?
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
53
Describe the impact that blocks and methods have on variables with the same name.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
54
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 66 flashcards in this deck.
Unlock Deck
k this deck
55
  Explain why the highlighted statements will result in an illegal action.
Explain why the highlighted statements will result in an illegal action.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
56
Describe how a Java variable comes into and out of scope.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
57
What does it mean when a variable overrides another variable? 
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
58
What is automatic type promotion in method calls? Give an example of how this works.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
59
Describe a block and define an outer block and an inner block.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
60
What is a reference and what is the meaning of the keyword this ?
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
61
  In the above code, if the simpleMethod() method received a double or integer value, the resulting output is Method receives double parameter. Explain how Java can promote one data type to another when a parameter is passed to a method.
In the above code, if the simpleMethod() method received a double or integer value, the resulting output is "Method receives double parameter". Explain how Java can promote one data type to another when a parameter is passed to a method.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
62
What is the phenomenon called shadowing?
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
63
  Explain and describe the this reference. How is the this reference used in each of the above methods?
Explain and describe the this reference. How is the this reference used in each of the above methods?
Unlock Deck
Unlock for access to all 66 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 66 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 66 flashcards in this deck.
Unlock Deck
k this deck
66
  In the above code, what would happen if calculateInterest was passed the values of 100 for the bal and .10 for the interest rate? What would happen if calculateInterest was passed the values of 100 for the bal and 10 for the interest rate? Why is it a problem when these values are passed to the calculateInterest method, and what would be a possible solution to fix the problem?
In the above code, what would happen if calculateInterest was passed the values of 100 for the bal and .10 for the interest rate? What would happen if calculateInterest was passed the values of 100 for the bal and 10 for the interest rate? Why is it a problem when these values are passed to the calculateInterest method, and what would be a possible solution to fix the problem?
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 66 flashcards in this deck.