Deck 8: Designing Classes
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/88
Play
Full screen (f)
Deck 8: Designing Classes
1
A class (ClassOne) is considered to have a dependency on another class (ClassTwo) under which of the following conditions?
A)ClassOne and ClassTwo both use a third class ClassThree.
B)The public interfaces of both classes are cohesive.
C)ClassTwo uses objects of ClassOne.
D)ClassOne uses objects of ClassTwo.
A)ClassOne and ClassTwo both use a third class ClassThree.
B)The public interfaces of both classes are cohesive.
C)ClassTwo uses objects of ClassOne.
D)ClassOne uses objects of ClassTwo.
ClassOne uses objects of ClassTwo.
2
Which class category has static methods and constants, but no objects?
A)Real-life entity abstraction
B)Actor class
C)Utility class
D)Concept class
A)Real-life entity abstraction
B)Actor class
C)Utility class
D)Concept class
Utility class
3
Which of the following is a true statement regarding consistency in coding?
A)Inconsistencies nearly always produce fatal flaws.
B)Inconsistencies are an annoyance, because they can be so easily avoided.
C)Consistency is not important in programming.
D)Consistency always requires extra coding.
A)Inconsistencies nearly always produce fatal flaws.
B)Inconsistencies are an annoyance, because they can be so easily avoided.
C)Consistency is not important in programming.
D)Consistency always requires extra coding.
Inconsistencies are an annoyance, because they can be so easily avoided.
4
Which of the following describes the first thing you should do when beginning a new object-oriented programming activity?
A)Consider how many concepts each class should represent.
B)Determine which categories of classes may be needed for the project.
C)Decide what combination of functions and methods are appropriate for the project.
D)Identify the objects and the classes to which they belong.
A)Consider how many concepts each class should represent.
B)Determine which categories of classes may be needed for the project.
C)Decide what combination of functions and methods are appropriate for the project.
D)Identify the objects and the classes to which they belong.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following questions should you ask to help determine if a proposed class design is on the right track?
A)Does the class name contain eight or fewer characters?
B)Is the class name a verb?
C)Can I visualize an object of the class?
D)Does the class name describe the tasks that this class will accomplish?
A)Does the class name contain eight or fewer characters?
B)Is the class name a verb?
C)Can I visualize an object of the class?
D)Does the class name describe the tasks that this class will accomplish?
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
6
Given the following class definition, which of the following are considered part of the class's public interface?
A)objectCounter and updateCounter
B)DIME_VALUE and objectCounter
C)DIME_VALUE and updateDimes
D)updateDimes and updateCounter

A)objectCounter and updateCounter
B)DIME_VALUE and objectCounter
C)DIME_VALUE and updateDimes
D)updateDimes and updateCounter
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following represents a good strategy regarding cohesion and class dependencies?
A)Maximize cohesion and remove unnecessary dependencies.
B)Minimize cohesion and remove unnecessary dependencies.
C)Maximize both cohesion and dependencies.
D)Minimize cohesion and maximize dependencies.
A)Maximize cohesion and remove unnecessary dependencies.
B)Minimize cohesion and remove unnecessary dependencies.
C)Maximize both cohesion and dependencies.
D)Minimize cohesion and maximize dependencies.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
8
General Java variable naming conventions would suggest that a variable named NICKEL_VALUE would most probably be declared using which of the following combinations of modifiers?
A)public void final
B)public static final double
C)private static double
D)private static
A)public void final
B)public static final double
C)private static double
D)private static
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
9
A UML class diagram would be most useful in visually illustrating which of the following?
A)the cohesiveness of a class's interface.
B)the amount of complexity of a class's interface.
C)dependencies between classes.
D)relationships between classes and their interfaces.
A)the cohesiveness of a class's interface.
B)the amount of complexity of a class's interface.
C)dependencies between classes.
D)relationships between classes and their interfaces.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following most likely indicates that you have chosen a good name for your class?
A)The name consists of a single word.
B)You can tell by the name what an object of the class is supposed to represent.
C)You can easily determine by the name how many concepts the class represents.
D)The name is the task the class will perform.
A)The name consists of a single word.
B)You can tell by the name what an object of the class is supposed to represent.
C)You can easily determine by the name how many concepts the class represents.
D)The name is the task the class will perform.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
11
Which type of method modifies the object on which it is invoked?
A)Constructor method.
B)Static method.
C)Accessor method.
D)Mutator method.
A)Constructor method.
B)Static method.
C)Accessor method.
D)Mutator method.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
12
Why does the Scanner class belong to the category of classes known as actors?
A)It acts as an interface between your program and the command line.
B)It serves as an abstract entity that represents a user of your program.
C)It plays an important part in streamlining the operation of your system.
D)It performs a task, such as scanning a stream for numbers and characters.
A)It acts as an interface between your program and the command line.
B)It serves as an abstract entity that represents a user of your program.
C)It plays an important part in streamlining the operation of your system.
D)It performs a task, such as scanning a stream for numbers and characters.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following describes an immutable class?
A)A class where all accessor and mutator methods are public.
B)A class that has no accessor methods, but does have mutator methods.
C)A class that has accessor methods, but does not have mutator methods.
D)A class that has both accessor and mutator methods.
A)A class where all accessor and mutator methods are public.
B)A class that has no accessor methods, but does have mutator methods.
C)A class that has accessor methods, but does not have mutator methods.
D)A class that has both accessor and mutator methods.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following would be an appropriate name for a game-related class?
A)CompletedLevelOne
B)InitialLevel
C)ResetCurrentLevel
D)AscendToFinalLevel
A)CompletedLevelOne
B)InitialLevel
C)ResetCurrentLevel
D)AscendToFinalLevel
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following is a good indicator that a class is overreaching and trying to accomplish too much?
A)The class has more constants than methods
B)The public interface refers to multiple concepts
C)The public interface exposes private features
D)The class is both cohesive and dependent.
A)The class has more constants than methods
B)The public interface refers to multiple concepts
C)The public interface exposes private features
D)The class is both cohesive and dependent.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
16
Under which of the following conditions would the public interface of a class be considered cohesive?
A)All of its features are public and none of its features are static.
B)The quality of the public interface is rated as moderate to high.
C)All of its features are related to the concept that the class represents.
D)It is obvious that the public interface refers to multiple concepts.
A)All of its features are public and none of its features are static.
B)The quality of the public interface is rated as moderate to high.
C)All of its features are related to the concept that the class represents.
D)It is obvious that the public interface refers to multiple concepts.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following is considered by the text to be the most important consideration when designing a class?
A)Each class should represent an appropriate mathematical concept.
B)Each class should represent a single concept or object from the problem domain.
C)Each class should represent no more than three specific concepts.
D)Each class should represent multiple concepts only if they are closely related.
A)Each class should represent an appropriate mathematical concept.
B)Each class should represent a single concept or object from the problem domain.
C)Each class should represent no more than three specific concepts.
D)Each class should represent multiple concepts only if they are closely related.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
18
A class named CurrencyTranslator would most probably fall into which of the following class categories?
A)Actor classes
B)Starter classes
C)Abstract entities
D)Utility classes
A)Actor classes
B)Starter classes
C)Abstract entities
D)Utility classes
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
19
The String class is an example of which of the following types of classes?
A)Static class.
B)Immutable class.
C)Abstract class.
D)Mutable class.
A)Static class.
B)Immutable class.
C)Abstract class.
D)Mutable class.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
20
Why is it generally considered good practice to minimize dependencies between classes?
A)Low dependencies increases the operational efficiency of a program.
B)High dependency implies less interface cohesion.
C)High dependency increases program maintenance and hinders code reuse.
D)Low dependency decreases the probability of code redundancy.
A)Low dependencies increases the operational efficiency of a program.
B)High dependency implies less interface cohesion.
C)High dependency increases program maintenance and hinders code reuse.
D)Low dependency decreases the probability of code redundancy.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
21
Which statement is true for syntactically correct classes?
A)They must have both mutator and accessor methods.
B)They must have accessors, and optionally may have mutators.
C)They must have mutators, and optionally may have accessors.
D)They may have either mutator or accessor methods, or both.
A)They must have both mutator and accessor methods.
B)They must have accessors, and optionally may have mutators.
C)They must have mutators, and optionally may have accessors.
D)They may have either mutator or accessor methods, or both.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
22
Mutator methods exhibit which of the following types of side effect?
A)Modification of private instance variables.
B)Modification of parameter variable.
C)Production of printed output.
D)Acceptance of text input.
A)Modification of private instance variables.
B)Modification of parameter variable.
C)Production of printed output.
D)Acceptance of text input.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following is true regarding side effects of methods?
A)Modification of private instance variables should be restricted to primitive data types.
B)Modification of parameter varibles should never be allowed.
C)Side effects involving standard output should be limited to String data.
D)Minimize side effects that go beyond modification of private instance variables.
A)Modification of private instance variables should be restricted to primitive data types.
B)Modification of parameter varibles should never be allowed.
C)Side effects involving standard output should be limited to String data.
D)Minimize side effects that go beyond modification of private instance variables.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following is an example of an immutable class?
A)Math.
B)Scanner.
C)String.
D)System.
A)Math.
B)Scanner.
C)String.
D)System.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
25
Which of the following is true regarding objects created from immutable classes?
A)It is safe to give out references to immutable class objects freely.
B)An immutable object can only be modified by its mutator method.
C)It is not advisable to return immutable object references from accessor methods.
D)Immutable classes do not have constructors.
A)It is safe to give out references to immutable class objects freely.
B)An immutable object can only be modified by its mutator method.
C)It is not advisable to return immutable object references from accessor methods.
D)Immutable classes do not have constructors.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
26
Which is an example of a class that needs to keep track of a total, i.e., a quantity that can go up and down?
A)The string class.
B)The Scanner class.
C)The BankAccount class.
D)The Shape class.
A)The string class.
B)The Scanner class.
C)The BankAccount class.
D)The Shape class.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
27
What is the name of a class that has only accessor methods and no mutators methods?
A)Utility
B)Static
C)Immutable
D)Actor
A)Utility
B)Static
C)Immutable
D)Actor
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
28
Consider the partial Date class below which represents a day of the year.
What type of method is getMonth?
A)mutator
B)constructor
C)accessor
D)immutable

A)mutator
B)constructor
C)accessor
D)immutable
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
29
Why can't Java methods change parameters of primitive type?
A)Java methods can have no actual impact on parameters of any type.
B)Parameters of primitive type are considered by Java methods to be local variables.
C)Parameters of primitive type are immutable.
D)Java methods cannot accept parameters of primitive type.
A)Java methods can have no actual impact on parameters of any type.
B)Parameters of primitive type are considered by Java methods to be local variables.
C)Parameters of primitive type are immutable.
D)Java methods cannot accept parameters of primitive type.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
30
In Java, which of the following mechanisms describe the copying of an object reference into a parameter variable?
A)Call-by-reference .
B)Call-by-value.
C)Call-by-precondition.
D)Call-by-object.
A)Call-by-reference .
B)Call-by-value.
C)Call-by-precondition.
D)Call-by-object.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following can potentially be changed by a Java method?
A)An object reference parameter.
B)The state of an object reference parameter's attribute.
C)A primitive parameter.
D)A String parameter.
A)An object reference parameter.
B)The state of an object reference parameter's attribute.
C)A primitive parameter.
D)A String parameter.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
32
Judging by the name of the method, which of the following methods would most likely be a mutator method?
A)getListOfDeposits.
B)printAccountBalance.
C)isOverdrawn.
D)updateDeposit.
A)getListOfDeposits.
B)printAccountBalance.
C)isOverdrawn.
D)updateDeposit.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
33
Given the following method header, other would be classified as which of the following parameter types?
public void transfer(double amount, BankAccount other)
A)Private instance variable.
B)Parameter variable.
C)Global variable.
D)Mutable variable.
public void transfer(double amount, BankAccount other)
A)Private instance variable.
B)Parameter variable.
C)Global variable.
D)Mutable variable.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
34
Consider the partial Date class below which represents a day of the year.
What type of method is setMonth?
A)mutator
B)accessor
C)constructor
D)immutable

A)mutator
B)accessor
C)constructor
D)immutable
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
35
Which of the following does NOT describe a particular side effect related to standard output?
A)Messages printed in a particular language may be of limited usefulness.
B)Methods that rely on standard output have limited usefulness in embedded systems.
C)Programmers may be surprised by unexpected method actions.
D)Programmers may need values for purposes other than informational messages.
A)Messages printed in a particular language may be of limited usefulness.
B)Methods that rely on standard output have limited usefulness in embedded systems.
C)Programmers may be surprised by unexpected method actions.
D)Programmers may need values for purposes other than informational messages.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following statements is true regarding method parameters in Java?
A)All method parameters use the call-by-value mechanism.
B)Only method parameters of primitive type use the call-by-value mechanism.
C)All method parameters use the call-by-reference mechanism.
D)Only method parameters of object type use the call-by-value mechanism.
A)All method parameters use the call-by-value mechanism.
B)Only method parameters of primitive type use the call-by-value mechanism.
C)All method parameters use the call-by-reference mechanism.
D)Only method parameters of object type use the call-by-value mechanism.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
37
Consider the partial Date class below (method signatures and instance variables) which represents a day of the year:
What is wrong with this design?
A)You cannot return this from a method.
B)It uses lastDayOfMonth, a private method of the class.
C)It has the side effect of changing the Date.
D)Since it returns a Date other than this one, the class is not consistent.

A)You cannot return this from a method.
B)It uses lastDayOfMonth, a private method of the class.
C)It has the side effect of changing the Date.
D)Since it returns a Date other than this one, the class is not consistent.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
38
Which of the following classifications of method behavior produces acceptable side effects?
A)Accessor methods that do not change parameter variables.
B)Mutator methods that do not change parameter variables.
C)Any method that changes a parameter variable.
D)Any method that changes another object.
A)Accessor methods that do not change parameter variables.
B)Mutator methods that do not change parameter variables.
C)Any method that changes a parameter variable.
D)Any method that changes another object.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
39
Consider the method in the following code snippet:
Which of the following statements would not be a valid criticism of the design of this method?
A)It violates the design rule of minimizing the dependencies between classes.
B)It assumes that the message will always need to be in English.
C)It might not work in an embedded system.
D)It should not be a separate method since it is only one line long.

A)It violates the design rule of minimizing the dependencies between classes.
B)It assumes that the message will always need to be in English.
C)It might not work in an embedded system.
D)It should not be a separate method since it is only one line long.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
40
Which of the following classifications of method behavior is accurate?
A)Methods that do not change parameter variables always have side effects.
B)Methods that change parameter variables do not have side effects.
C)Methods that change parameter variables always have side effects.
D)Methods that do not change parameter variables never have side effects.
A)Methods that do not change parameter variables always have side effects.
B)Methods that change parameter variables do not have side effects.
C)Methods that change parameter variables always have side effects.
D)Methods that do not change parameter variables never have side effects.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
41
What mechanism is used by a class that is designed to collect and store a growing set of values?
A)A local variable.
B)A string.
C)An array list or array.
D)Auto-boxing.
A)A local variable.
B)A string.
C)An array list or array.
D)Auto-boxing.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
42
Where in a class should static variables be declared and initialized?
A)Inside the constructor method.
B)Inside the class, but outside of any method body.
C)Outside the class - in a separate designated static class.
D)Outside the class, but inside the same physical file.
A)Inside the constructor method.
B)Inside the class, but outside of any method body.
C)Outside the class - in a separate designated static class.
D)Outside the class, but inside the same physical file.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
43
When are statements in a class-level initialization block executed?
A)Before the code in the class constructor is executed.
B)Once when the class is loaded.
C)Whenever objects of the class are used to access methods.
D)After the code in the class constructor is executed.
A)Before the code in the class constructor is executed.
B)Once when the class is loaded.
C)Whenever objects of the class are used to access methods.
D)After the code in the class constructor is executed.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
44
Suppose an object is intended to store its current position in a 2D array using private instance variables and a mutator:
What problem could be encountered with the method moveLeft(), which is intended to move the current position of the object to the left one column on the grid?
A)The method should be changing the row instance variable.
B)The method should be incrementing the column instance variable.
C)The method might cause the instance variables to go out of the bounds of the 2D array.
D)The method should be changing local variables instead of instance variables.

A)The method should be changing the row instance variable.
B)The method should be incrementing the column instance variable.
C)The method might cause the instance variables to go out of the bounds of the 2D array.
D)The method should be changing local variables instead of instance variables.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
45
A static method can have which of the following types of parameters?
A)Only implicit parameters.
B)Only parameter variables.
C)Both implicit parameters parameter variables.
D)A static method cannot have parameter variables.
A)Only implicit parameters.
B)Only parameter variables.
C)Both implicit parameters parameter variables.
D)A static method cannot have parameter variables.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
46
Consider the following code snippet:
Which of the following statements is true?
A)It is illegal to declare the level1Cutoff variable within the process method
B)The code within the process method changes the value of the instance variable level1Cutoff for elite customers
C)The level1Cutoff variable within the process method does not change the level1Cutoff instance variable for elite customers
D)The level1Cutoff class variable cannot have the same name as the level1Cutoff local variable within the process method

A)It is illegal to declare the level1Cutoff variable within the process method
B)The code within the process method changes the value of the instance variable level1Cutoff for elite customers
C)The level1Cutoff variable within the process method does not change the level1Cutoff instance variable for elite customers
D)The level1Cutoff class variable cannot have the same name as the level1Cutoff local variable within the process method
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
47
Which of the following are considered members of a class?
A)Private instance variables and methods only.
B)All instance variables and methods.
C)Non-static instance variables and methods only.
D)Public instance variables and methods only.
A)Private instance variables and methods only.
B)All instance variables and methods.
C)Non-static instance variables and methods only.
D)Public instance variables and methods only.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
48
When an object is intended to set and manage properties, where should those properties be stored?
A)An array as a local variable in a method.
B)Instance variables.
C)The main method of the program.
D)An off-site database.
A)An array as a local variable in a method.
B)Instance variables.
C)The main method of the program.
D)An off-site database.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
49
It is common for certain classes to keep track of how many times certain events have occurred over the life of an object.This is done using
A)A private instance variable within the class.
B)A local variable within a mutator method.
C)A notification event to a helper class.
D)An array of objects.
A)A private instance variable within the class.
B)A local variable within a mutator method.
C)A notification event to a helper class.
D)An array of objects.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
50
Which of the following statements is generally true regarding static methods and variables?
A)The use of static variables and methods should be minimized.
B)The use of static variables and methods should be maximized.
C)A lot of static methods and variables indicate a well-designed object-oriented system.
D)Always choose static methods and variables over similar object-based implementations.
A)The use of static variables and methods should be minimized.
B)The use of static variables and methods should be maximized.
C)A lot of static methods and variables indicate a well-designed object-oriented system.
D)Always choose static methods and variables over similar object-based implementations.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
51
Why is a static variable also referred to as a class variable?
A)There is a single copy available to all objects of the class.
B)It is encapsulated within the class.
C)Each class has one and only one static variable.
D)It is stored in the separate class area of each object.
A)There is a single copy available to all objects of the class.
B)It is encapsulated within the class.
C)Each class has one and only one static variable.
D)It is stored in the separate class area of each object.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
52
Which of the following constitutes a common reason for creating a static method?
A)To encapsulate a computation that involves only numbers.
B)To implement a computation that only involves implicit parameters.
C)To test a computation prior to implementing it in a class.
D)To improve efficiency by reducing overhead associated with the use of objects.
A)To encapsulate a computation that involves only numbers.
B)To implement a computation that only involves implicit parameters.
C)To test a computation prior to implementing it in a class.
D)To improve efficiency by reducing overhead associated with the use of objects.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
53
Which of the following classes has a static variable that is commonly used when communicating with standard output?
A)Scanner.
B)String.
C)System.
D)Object.
A)Scanner.
B)String.
C)System.
D)Object.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
54
The use of the static keyword in a method declaration implies which of the following?
A)The method can only operate on immutable objects.
B)The method can only be called from within the main method.
C)The method cannot be overloaded.
D)The method cannot be invoked on an instance of an object.
A)The method can only operate on immutable objects.
B)The method can only be called from within the main method.
C)The method cannot be overloaded.
D)The method cannot be invoked on an instance of an object.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
55
Which of the following types of methods are invoked on objects?
A)Static method.
B)Class method.
C)Instance method.
D)Either static or instance methods.
A)Static method.
B)Class method.
C)Instance method.
D)Either static or instance methods.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
56
Which of the following statements regarding static methods is true?
A)Static methods are not very common.
B)Static methods should be liberally used within classes.
C)Use of static methods usually leads to good object-oriented design.
D)Static methods can be easily evolved to add more functionality.
A)Static methods are not very common.
B)Static methods should be liberally used within classes.
C)Use of static methods usually leads to good object-oriented design.
D)Static methods can be easily evolved to add more functionality.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
57
Consider the following code snippet:
If a program instantiates four objects using this class, which of the following statements will be true?
A)Each object will have a currentRewardPointBalance instance variable and a level1Cutoff instance variable.
B)All objects will share a single currentRewardPointBalance class variable and a level1Cutoff class variable.
C)Each object will have a currentRewardPointBalance instance variable, but all objects will share a level1Cutoff class variable.
D)All objects will share a currentRewardPointBalance class variable and each object will have a level1Cutoff instance variable.

A)Each object will have a currentRewardPointBalance instance variable and a level1Cutoff instance variable.
B)All objects will share a single currentRewardPointBalance class variable and a level1Cutoff class variable.
C)Each object will have a currentRewardPointBalance instance variable, but all objects will share a level1Cutoff class variable.
D)All objects will share a currentRewardPointBalance class variable and each object will have a level1Cutoff instance variable.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
58
When are statements in a class-level static initialization block executed?
A)Before the code in the class constructor is executed.
B)Once when the class is loaded.
C)Whenever objects of the class are used to access methods.
D)After the code in the class constructor is executed.
A)Before the code in the class constructor is executed.
B)Once when the class is loaded.
C)Whenever objects of the class are used to access methods.
D)After the code in the class constructor is executed.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
59
Suppose an object is intended to store its current position in a 2D array using private instance variables:

Which code represents a method that would move the current position of the object one column to the right on the grid?
A)

B)

C)

D)


Which code represents a method that would move the current position of the object one column to the right on the grid?
A)

B)

C)

D)

Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
60
In which of the following cases could a static variable be declared as something other than private?
A)When it will be accessed by multiple objects.
B)When implementing static constants.
C)When declared inside a private method.
D)Static variables should never be declared as anything but private.
A)When it will be accessed by multiple objects.
B)When implementing static constants.
C)When declared inside a private method.
D)Static variables should never be declared as anything but private.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
61
In order to solve complex tasks, you should apply an important skill:
A)organize classes based on performance and need.
B)learn to direct others with clear, simple instructions.
C)simplify the problem, and solve the simpler problem first.
D)involve users in the process from the very beginning.
A)organize classes based on performance and need.
B)learn to direct others with clear, simple instructions.
C)simplify the problem, and solve the simpler problem first.
D)involve users in the process from the very beginning.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
62
Can the method lastDayOfMonth be changed to be a static method by just changing the header to the following?
private static int lastDayOfMonth()
A)No.It could no longer access the month instance variable.
B)No.A class cannot have both static and non-static methods.
C)Yes.No other change is necessary.
D)Yes, but it must be changed to public as well.
private static int lastDayOfMonth()
A)No.It could no longer access the month instance variable.
B)No.A class cannot have both static and non-static methods.
C)Yes.No other change is necessary.
D)Yes, but it must be changed to public as well.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
63
A theater needs a TicketCounter to keep track of the number of tickets sold.There are two types of ticket: regular and discount.What instance data should be used for this class?
A)
B)
C)
D)
A)

B)

C)

D)

Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
64
Consider the Checker class below.
A)2 2
B)1 1
C)1 2
D)2 1

A)2 2
B)1 1
C)1 2
D)2 1
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
65
A new method, getMonthName, to get the name of the Date's month ("January", February", etc.) is to be added to the class Date.The Date class already has a class variable that stores the month as an integer.Which of the following headers should the new method have?
A)public String getMonthName(int month)
B)public String getMonthName()
C)public void getMonthName(String monthName)
D)public void getMonthName(int month, String monthName)
A)public String getMonthName(int month)
B)public String getMonthName()
C)public void getMonthName(String monthName)
D)public void getMonthName(int month, String monthName)
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
66
Which of the following is not a reason to place classes into a package?
A)to avoid name clashes
B)to organize related classes
C)to show authorship of source code for classes
D)to make it easier to include a set of frequently used but unrelated classes
A)to avoid name clashes
B)to organize related classes
C)to show authorship of source code for classes
D)to make it easier to include a set of frequently used but unrelated classes
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
67
A new class is proposed to collect information about a group of DVDs.A separate class containing information about a single DVD, named DVD, has already been created.Which of the following is the best design to store the data and size of this collection?
A)Have an ArrayList of DVD and use its size as the size of the collection.
B)Have an ArrayList of DVD and an integer representing the number of DVD objects in the collection.
C)Have an array of DVD and use its size as the size of the collection.
D)Have a single DVD variable representing the last DVD added and an integer representing the number of DVDs in the collection.
A)Have an ArrayList of DVD and use its size as the size of the collection.
B)Have an ArrayList of DVD and an integer representing the number of DVD objects in the collection.
C)Have an array of DVD and use its size as the size of the collection.
D)Have a single DVD variable representing the last DVD added and an integer representing the number of DVDs in the collection.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
68
A new method, getMonthName, to get the name of the Date's month ("January", February", etc.) is to be added to the class Date.How will the instance variables need to be changed to handle this new method?
A)The type of the month instance variable will need to be changed to String.
B)A new String variable called monthName will need to be added to the class.
C)A new class called MonthNameAndNumber will need to be created to store both the name and number of the month and the type of the instance variable month will need to be changed to MonthNameAndNumber.
D)No change is needed.
A)The type of the month instance variable will need to be changed to String.
B)A new String variable called monthName will need to be added to the class.
C)A new class called MonthNameAndNumber will need to be created to store both the name and number of the month and the type of the instance variable month will need to be changed to MonthNameAndNumber.
D)No change is needed.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
69
What will have to change if the instance variables month and day of the Date class are replaced by the single instance integer variable dayOfTheYear?
A)The implementation of the methods will change, but the interface will not need to change.
B)The implementation of getDay will not change, but the implementations of the other methods will not change and the interface will not change.
C)The interface will need to change to remove setMonth, but no other parts of the interface will change.
D)All of the interface will need to be changed when the instance variables change.
A)The implementation of the methods will change, but the interface will not need to change.
B)The implementation of getDay will not change, but the implementations of the other methods will not change and the interface will not change.
C)The interface will need to change to remove setMonth, but no other parts of the interface will change.
D)All of the interface will need to be changed when the instance variables change.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
70
Consider the following code snippet:
Which of the following statements about the variable vehicleType is true?
A)It can be accessed by all classes in the same package as the Vehicle class.
B)It can be accessed only by code within the Vehicle class.
C)It can be accessed only by public methods declared within the Vehicle class.
D)It can be accessed only by private methods declared within the Vehicle class.

A)It can be accessed by all classes in the same package as the Vehicle class.
B)It can be accessed only by code within the Vehicle class.
C)It can be accessed only by public methods declared within the Vehicle class.
D)It can be accessed only by private methods declared within the Vehicle class.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
71
The best way to learn the strategy of how to break complex problems into simpler steps is to
A)read more material about programming language.
B)use pictures arranged in rows.
C)use a debugger to assess problem complexity and efficiency.
D)practice it.
A)read more material about programming language.
B)use pictures arranged in rows.
C)use a debugger to assess problem complexity and efficiency.
D)practice it.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
72
A new class is proposed to collect information about a group of DVDs.Which of the following is the best structure for this class?
A)Have separate classes for a single DVD and the entire DVD collection.
B)Have one class to store information about DVDs and the collection named DVDsInformation
C)Have one class to store information about the collection name and send information about the DVDs as simple data (integers, Strings, etc.)
D)Have one class to store information about a single DVD and just use an ArrayList to store the collection.
A)Have separate classes for a single DVD and the entire DVD collection.
B)Have one class to store information about DVDs and the collection named DVDsInformation
C)Have one class to store information about the collection name and send information about the DVDs as simple data (integers, Strings, etc.)
D)Have one class to store information about a single DVD and just use an ArrayList to store the collection.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
73
Consider the Checker class below.
A)1 2
B)1 1
C)2 1
D)2 2

A)1 2
B)1 1
C)2 1
D)2 2
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
74
Under which of the following conditions must you qualify the name of a public class member?
A)If it is to be used outside its class.
B)If it is to be used inside its class.
C)Public class members must always be qualified.
D)Public class members never need to be qualified.
A)If it is to be used outside its class.
B)If it is to be used inside its class.
C)Public class members must always be qualified.
D)Public class members never need to be qualified.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
75
A new class is proposed to collect information about a group of DVDs.Which of the following is the best name for this class?
A)DVDCollection
B)DVD
C)StoreDVDInformation
D)Collection
A)DVDCollection
B)DVD
C)StoreDVDInformation
D)Collection
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
76
To use a public variable or method outside of its class, you must ____ the name.
A)bind
B)encapsulate
C)instantiate
D)qualify
A)bind
B)encapsulate
C)instantiate
D)qualify
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
77
A theater needs a TicketCounter to keep track of the number of tickets sold.There are two types of ticket: regular and discount.Which technique would be the best approach to printing the number of tickets sold?
A)Create a toString() method in the class that creates a representation with the number of discount and regular priced tickets sold.
B)Create a print() method that will print out the number of discount and regular priced tickets sold.
C)Make the instance variables public so programs can access the values and print them.
D)Create a getValues(int regular, int discount) method that will return the number of discount and regular priced tickets sold.
A)Create a toString() method in the class that creates a representation with the number of discount and regular priced tickets sold.
B)Create a print() method that will print out the number of discount and regular priced tickets sold.
C)Make the instance variables public so programs can access the values and print them.
D)Create a getValues(int regular, int discount) method that will return the number of discount and regular priced tickets sold.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
78
If you do not include a package statement at the top of your class source file, its classes will be placed in which package?
A)java.lang
B)java.util
C)the default package, which has no name
D)java.awt
A)java.lang
B)java.util
C)the default package, which has no name
D)java.awt
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
79
Which of the following names would be considered to be qualified?
A)studentOne.getGraduationYear()
B)this.getGraduationYear()
C)getGraduationYear()
D)getGraduationYear().print()
A)studentOne.getGraduationYear()
B)this.getGraduationYear()
C)getGraduationYear()
D)getGraduationYear().print()
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck
80
Which action is not accomplished by using the import directive?
A)Reference to a class within a package without having to fully qualify it.
B)The ability to use all classes within a specific package.
C)The organization of packages into groups.
D)Ability to document in one place all class resources used in a program.
A)Reference to a class within a package without having to fully qualify it.
B)The ability to use all classes within a specific package.
C)The organization of packages into groups.
D)Ability to document in one place all class resources used in a program.
Unlock Deck
Unlock for access to all 88 flashcards in this deck.
Unlock Deck
k this deck