Chapter 1 Questions
Multiple Choice Questions
1. The specifications of an ADT’s operations indicate ______.
a. what the operations do
b. how to implement the operations
c. how to store the data in the ADT
d. how to carry out the operations
2. Data structures are part of an ADT’s ______.
a. definition
b. implementation
c. specifications
d. usage
3. A(n) ______ allows two modules to communicate with each other.
a. data structure
b. axiom
c. interface
d. client
4. An ADT’s ______ govern(s) what its operations are and what they do.
a. specifications
b. implementation
c. documentation
d. data structure
5. When each module performs one well-defined task, we say that it is ___.
a. loosely coupled
b. highly coupled
c. cohesive
d. not easily reused
6. When should an operation contract be written?
a. during analysis
b. after coding
c. at the same time as user documentation
d. when taking initial notes from client
7. What information is included in the operation contract?
a. the method’s interface
b. data flow among the modules
c. assumptions about input
d. all of these
8. What kind of interface contains a method if and only that method is essential to that class’s
responsibilities?
a. complete
b. minimal
Chapter 1 Questions
c. expanded
d. compact
9. What must be known about the ADT Bag in order to use it in a program?
a. how entries in the bag are represented
b. how bag operations are implemented
c. how many entries can be stored in the bag
d. the interface of the bag
10. According the CRC specifications for a Bag, which of the following behaviors would not be one of the
responsibilities of the class Bag?
a. See if the bag is empty
b. See if the bag is full
c. Look at all the objects in the bag
d. Count the number of times a certain object occurs in the bag
11. A client program depends solely on the ______ of the ADT.
a. data members
b. structure
c. implementation
d. behavior
12. What should a programmer do before implementing a recently designed class?
a. write code that uses the class
b. check comments that document specifications
c. adjust the design when problems are discovered
d. all of these
13. Object-oriented programming views a program as ______.
a. a sequence of actions
b. a collection of classes
c. a group of methods
d. an interaction among objects
14. An ADT’s operations are known as its ______.
a. axioms
b. methods
c. variables
d. interfaces
15. Encapsulation combines an ADT’s data with its operations to form a(n) ______.
a. exception
b. method
c. object
d. variable
Chapter 1 Questions
a. class
b. method
c. data field
d. object
17. A C++ class contains data members and ______.
a. clients
b. interfaces
c. methods
d. data structures
18. A(n) ______ is an instance of a class.
a. method
b. data field
c. interface
d. object
19. A(n) ______ is a class that inherits the members of another class.
a. base class
b. superclass
c. abstract class
d. subclass
20. A function can indicate that an error has occurred by ______ an exception.
a. throwing
b. catching
c. implementing
d. declaring
21. To ______ an exception means to deal with the error condition.
a. declare
b. catch
c. implement
d. try
22. Which of the following are ways to address unusual situations?
a. simply assume the invalid situation will never occur
b. guess at the client’s intention
c. return a value that signals a problem
d. all of the above are options
23. For the method remove(anEntry) of the ADT Bag, what would be the output of the method?
a. anEntry
b. nothing
c. true or false
d. the previous position of anEntry in the bag
Chapter 1 Questions
24. What is the task of the toVector() method of the ADT Bag?
a. copy the entries of the bag into a vector
b. vector the entries to the printer
c. test to see if there is a vector to the bag
d. remove all objects from the bag
25. Understanding what the problem is and what the requirements of a solution are is called
a. Object Oriented Analysis
b. Object Oriented Design
c. Object Oriented Solution
d. Algorithmic Oriented Design
26. Objects collaborate when they
a. are cohesive
b. are used by a programming team
c. send each other messages
d. model a real life situation
27. Which of the following could not be a module?
a. a standalone function
b. a data member
c. a class method
d. a class itself
Chapter 1 Questions
True/False Questions
1. According to the principle of information hiding, a module should be completely isolated from other
modules.
2. Data structures are part of an ADT’s implementation.
3. An abstract data type is another name for a data structure.
4. An interface for a class that allows programmers to accomplish any reasonable task is called a complete
interface.
5. It is possible to use one ADT to implement another ADT.
6. An application can use the operations of an ADT without knowing how the ADT is implemented.
7. By default, all members in a class are public.
8. A highly cohesive module is less robust.
9. Highly coupled modules should be avoided.
10. Any instance of a subclass can be used in a program anywhere that an instance of the superclass can be
used.
Chapter 1 Questions
Short Answer Questions
1. What are some of the benefits of modularity?
2. What is functional abstraction?
3. What is information hiding?
4. What are the three types of operations on a data collection?
5. What is data abstraction?
6. What is an abstract data type (ADT)?
7. What is a data structure?
8. What does an operation contract do?
9. What are some ways you can address unusual situations?
10. What is a bag?
11. Define the client of a class?
12. What is the purpose of an exception?
13. What does inheritance allow the system designer to do?
Chapter 1 Questions
14. What are the three principles of object oriented programming?
15. What are the advantages of a highly cohesive module?