Deck 7: Object-Oriented Design

Full screen (f)
exit full mode
Question
In black-box testing, the tester should already know something about how the program is implemented so that he/she can more carefully identify what portion(s) of the software may lead to errors.
Use Space or
up arrow
down arrow
to flip the card.
Question
It is not possible to test out any single method or class of a system until the entire system has been developed, and so all testing is postponed until after the implementation phase.
Question
In general, spending more time in development to ensure better software will

A) shorten testing time
B) slightly reduce maintenance efforts
C) slightly increase maintenance efforts
D) greatly reduce maintenance efforts
E) not alter the time it takes for any other stage
Question
If classes C1 and C2 both implement an interface Cint, which has a method, whichIsIt, and if C1 c = new C1(); is performed at one point of the program, then a later instruction
c.whichIsIt(); will invoke the whichIsIt method defined in C1.
Question
During program development, software requirements specify

A) how the program will accomplish the task
B) what task the program must perform
C) how to divide the task into subtasks
D) how to test the program when it is done
E) All of these
Question
The most important decisions regarding the development of a system are made during the implementation phase while code is actively being written.
Question
Once we have implemented the solution, we are not done with the problem because

A) the solution may not be the best or most efficient
B) the solution may have errors and need testing and fixing before we are done
C) the solution may, at a later date, need revising to handle new specifications
D) the solution may, at a later date, need revising because of new programming language features
E) All of these
Question
Any class can implement an interface, but no classes can implement more than a single interface.
Question
Assume that the class Bird has a static method fly(). If b is a Bird, then to invoke fly, you could do Bird.fly();.
Question
The idea of having programmers and developers meet in order to critique a software design or implementation is known as

A) an interview
B) a walkthrough
C) prototyping
D) aggregation
E) evolutionary development
Question
Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header.
Question
The graphical effect caused when a shape seems to resize as the mouse is dragged is known as rubberbanding.
Question
Unlike the String class where you must pass a message to an object (instance) of the class, in order to use the Math class, you pass messages directly to the class name, as in Math.sqrt().
Question
Interface classes cannot be extended but classes that implement interfaces can be extended.
Question
All objects implement Comparable.
Question
Of the various phases in software development, which of the following is usually the lengthiest?

A) specification
B) design
C) implementation
D) testing
E) maintenance
Question
Modifying a program in order to eliminate deficiencies is done in the __________ phase of the development cycle.

A) design
B) implementation
C) testing
D) use
E) maintenance
Question
It is easier to correct errors found in a program if

A) they are identified early in the development cycle
B) they are identified during testing
C) they are identified during program use
D) they are identified during maintenance
E) All of the above are equally true; errors are easily corrected at any of these stages
Question
The versions of an overloaded method are distinguished by the number, type, and order of their parameters.
Question
The activities of the development cycle are generally thought to

A) be strictly linear
B) be rigidly ordered
C) overlap
D) have optional steps
E) both A and B are true
Question
Having multiple class methods of the same name where each method has a different number of or type of parameters is known as

A) encapsulation
B) information hiding
C) tokenizing
D) importing
E) method overloading
Question
Explain the difference between implementing an interface and a derived class.
Question
Which of the following would not be considered an algorithm?

A) a recipe
B) a computer program
C) pseudocode
D) a shopping list
E) travel directions
Question
Define an interface class that contains two int constants, X = 5 and Y = 10 and one int method called useXY which receives no parameters. Call your interface class XYClass.
Question
Refer to Code Description Ch 07-1: Which of the following method headers would properly define the method needed to make this class Comparable? (cp designates ChessPiece)

A) public boolean comparable(Object cp)
B) public int comparable(Object cp)
C) public int compareTo(Object cp)
D) public int compareTo()
E) public boolean compareTo(Object cp)
Question
Which of the following methods is a static method? The class in which the method is defined is given inside the parentheses following the method name.

A) equals(String)
B) toUpperCase(String)
C) sqrt(Math)
D) format(DecimalFormat)
E) None of these
Question
In order to create a constant, you would use which of the following Java words?

A) private
B) static
C) int
D) final
E) class
Question
Static methods cannot

A) reference instance data
B) reference non-static instance data
C) reference other objects
D) invoke other static methods
E) invoke other non-static methods
Question
In which phase of program development would you expect the programmer(s) to determine the classes and objects needed?

A) software requirements
B) software design
C) software implementation
D) software testing
E) this could occur at any time
Question
Abstract methods are used when defining

A) interface classes
B) derived classes
C) classes that have no constructor
D) arrays
E) classes that have no methods
Question
An example of an aggregation relationship is

A) parent and child
B) animal and dog
C) teacher and computer
D) phone and fax machine
E) All of these
Question
In order to implement Comparable in a class, what method(s) must be defined in that class?

A) equals
B) compares
C) both lessThan and greaterThan
D) compareTo
E) both compares and equals
Question
The goal of testing is to

A) ensure that the software has no errors
B) find syntax errors
C) find logical and run-time errors
D) evaluate how well the software meets the original requirements
E) give out-of-work programmers something to do
Question
It is important to dissect a problem into manageable pieces before trying to solve the problem because

A) most problems are too complex to be solved as a single, large activity
B) most problems are solved by multiple people and it is easy to assign each piece to a separate person
C) it is easier to integrate small pieces of a program into one program than it is to integrate one big chunk of code into one program
D) the first solution may not solve the problem correctly
E) all of these
Question
In which phase of program development would you expect the programmer(s) to create the pseudocode?

A) software requirements
B) software design
C) software implementation
D) software testing
E) this could occur at any time
Question
Assume a class Foo implements Comparable. Without knowing anything else about the Foo class, write an equals method that returns true if the Foo parameter passed to this Foo is equal to this Foo as determined by using the implementation of Comparable.
Question
If a programmer follows the four phases of program development as intended, which of the four phases should require the least amount of creativity?

A) software requirements
B) software design
C) software implementation
D) software testing
E) all four levels require equal creativity
Question
Provide a reason why a method would be declared static.
Question
Provide a reason why an instance data would be declared static.
Question
An object that refers to part of itself within its own methods can use which of the following reserved words to denote this relationship?

A) inner
B) i
C) private
D) this
E) static
Question
In what way is black-box testing better than glass-box testing? In what way is glass-box testing better than black-box testing?
Question
Refer to Code Description Ch 07-1: To implement Comparable for the ChessPiece class, the current ChessPiece's type is compared to a ChessPiece passed as a parameter. The method should return 0 if the types are equal, -1 if this piece's type is a lesser piece than the parameter's type, and 1 if this piece's type is a greater piece than the parameter's type. Create this code.
Question
Write code that outputs all of the int values between 1 and 100 with five values per line, and each of those five values spaced out equally. Use a single for loop to solve this problem.
Question
Refer to Code Description Ch 07-1: Write a static method that is passed two ChessPieces and determines if the two pieces are owned by the same player. It should return true or false.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/44
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Object-Oriented Design
1
In black-box testing, the tester should already know something about how the program is implemented so that he/she can more carefully identify what portion(s) of the software may lead to errors.
False
2
It is not possible to test out any single method or class of a system until the entire system has been developed, and so all testing is postponed until after the implementation phase.
False
3
In general, spending more time in development to ensure better software will

A) shorten testing time
B) slightly reduce maintenance efforts
C) slightly increase maintenance efforts
D) greatly reduce maintenance efforts
E) not alter the time it takes for any other stage
D
4
If classes C1 and C2 both implement an interface Cint, which has a method, whichIsIt, and if C1 c = new C1(); is performed at one point of the program, then a later instruction
c.whichIsIt(); will invoke the whichIsIt method defined in C1.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
5
During program development, software requirements specify

A) how the program will accomplish the task
B) what task the program must perform
C) how to divide the task into subtasks
D) how to test the program when it is done
E) All of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
6
The most important decisions regarding the development of a system are made during the implementation phase while code is actively being written.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
7
Once we have implemented the solution, we are not done with the problem because

A) the solution may not be the best or most efficient
B) the solution may have errors and need testing and fixing before we are done
C) the solution may, at a later date, need revising to handle new specifications
D) the solution may, at a later date, need revising because of new programming language features
E) All of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
8
Any class can implement an interface, but no classes can implement more than a single interface.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
9
Assume that the class Bird has a static method fly(). If b is a Bird, then to invoke fly, you could do Bird.fly();.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
10
The idea of having programmers and developers meet in order to critique a software design or implementation is known as

A) an interview
B) a walkthrough
C) prototyping
D) aggregation
E) evolutionary development
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
11
Formal parameters are those that appear in the method call and actual parameters are those that appear in the method header.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
12
The graphical effect caused when a shape seems to resize as the mouse is dragged is known as rubberbanding.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
13
Unlike the String class where you must pass a message to an object (instance) of the class, in order to use the Math class, you pass messages directly to the class name, as in Math.sqrt().
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
14
Interface classes cannot be extended but classes that implement interfaces can be extended.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
15
All objects implement Comparable.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
16
Of the various phases in software development, which of the following is usually the lengthiest?

A) specification
B) design
C) implementation
D) testing
E) maintenance
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
17
Modifying a program in order to eliminate deficiencies is done in the __________ phase of the development cycle.

A) design
B) implementation
C) testing
D) use
E) maintenance
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
18
It is easier to correct errors found in a program if

A) they are identified early in the development cycle
B) they are identified during testing
C) they are identified during program use
D) they are identified during maintenance
E) All of the above are equally true; errors are easily corrected at any of these stages
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
19
The versions of an overloaded method are distinguished by the number, type, and order of their parameters.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
20
The activities of the development cycle are generally thought to

A) be strictly linear
B) be rigidly ordered
C) overlap
D) have optional steps
E) both A and B are true
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
21
Having multiple class methods of the same name where each method has a different number of or type of parameters is known as

A) encapsulation
B) information hiding
C) tokenizing
D) importing
E) method overloading
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
22
Explain the difference between implementing an interface and a derived class.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following would not be considered an algorithm?

A) a recipe
B) a computer program
C) pseudocode
D) a shopping list
E) travel directions
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
24
Define an interface class that contains two int constants, X = 5 and Y = 10 and one int method called useXY which receives no parameters. Call your interface class XYClass.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
25
Refer to Code Description Ch 07-1: Which of the following method headers would properly define the method needed to make this class Comparable? (cp designates ChessPiece)

A) public boolean comparable(Object cp)
B) public int comparable(Object cp)
C) public int compareTo(Object cp)
D) public int compareTo()
E) public boolean compareTo(Object cp)
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following methods is a static method? The class in which the method is defined is given inside the parentheses following the method name.

A) equals(String)
B) toUpperCase(String)
C) sqrt(Math)
D) format(DecimalFormat)
E) None of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
27
In order to create a constant, you would use which of the following Java words?

A) private
B) static
C) int
D) final
E) class
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
28
Static methods cannot

A) reference instance data
B) reference non-static instance data
C) reference other objects
D) invoke other static methods
E) invoke other non-static methods
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
29
In which phase of program development would you expect the programmer(s) to determine the classes and objects needed?

A) software requirements
B) software design
C) software implementation
D) software testing
E) this could occur at any time
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
30
Abstract methods are used when defining

A) interface classes
B) derived classes
C) classes that have no constructor
D) arrays
E) classes that have no methods
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
31
An example of an aggregation relationship is

A) parent and child
B) animal and dog
C) teacher and computer
D) phone and fax machine
E) All of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
32
In order to implement Comparable in a class, what method(s) must be defined in that class?

A) equals
B) compares
C) both lessThan and greaterThan
D) compareTo
E) both compares and equals
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
33
The goal of testing is to

A) ensure that the software has no errors
B) find syntax errors
C) find logical and run-time errors
D) evaluate how well the software meets the original requirements
E) give out-of-work programmers something to do
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
34
It is important to dissect a problem into manageable pieces before trying to solve the problem because

A) most problems are too complex to be solved as a single, large activity
B) most problems are solved by multiple people and it is easy to assign each piece to a separate person
C) it is easier to integrate small pieces of a program into one program than it is to integrate one big chunk of code into one program
D) the first solution may not solve the problem correctly
E) all of these
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
35
In which phase of program development would you expect the programmer(s) to create the pseudocode?

A) software requirements
B) software design
C) software implementation
D) software testing
E) this could occur at any time
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
36
Assume a class Foo implements Comparable. Without knowing anything else about the Foo class, write an equals method that returns true if the Foo parameter passed to this Foo is equal to this Foo as determined by using the implementation of Comparable.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
37
If a programmer follows the four phases of program development as intended, which of the four phases should require the least amount of creativity?

A) software requirements
B) software design
C) software implementation
D) software testing
E) all four levels require equal creativity
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
38
Provide a reason why a method would be declared static.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
39
Provide a reason why an instance data would be declared static.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
40
An object that refers to part of itself within its own methods can use which of the following reserved words to denote this relationship?

A) inner
B) i
C) private
D) this
E) static
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
41
In what way is black-box testing better than glass-box testing? In what way is glass-box testing better than black-box testing?
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
42
Refer to Code Description Ch 07-1: To implement Comparable for the ChessPiece class, the current ChessPiece's type is compared to a ChessPiece passed as a parameter. The method should return 0 if the types are equal, -1 if this piece's type is a lesser piece than the parameter's type, and 1 if this piece's type is a greater piece than the parameter's type. Create this code.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
43
Write code that outputs all of the int values between 1 and 100 with five values per line, and each of those five values spaced out equally. Use a single for loop to solve this problem.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
44
Refer to Code Description Ch 07-1: Write a static method that is passed two ChessPieces and determines if the two pieces are owned by the same player. It should return true or false.
Unlock Deck
Unlock for access to all 44 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 44 flashcards in this deck.