Data Abstraction & Problem Solving with C++ Walls and Mirrors 7e Frank Carrano, Timothy Henry
(Test Bank all Chapter)
- / 4
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Multiple Choice Questions
- The specifications of an ADT’s operations indicate ______.
- what the operations do
- how to implement the operations
- how to store the data in the ADT
- how to carry out the operations
Answer: a.
- Data structures are part of an ADT’s ______.
- definition
- implementation
- specifications
- usage
Answer: b.
- A(n) ______ allows two modules to communicate with each other.
- data structure
- axiom
- interface
- client
Answer: c.
- An ADT’s ______ govern(s) what its operations are and what they do.
- specifications
- implementation
- documentation
- data structure
Answer: a.
- When each module performs one well-defined task, we say that it is ___.
- loosely coupled
- highly coupled
- cohesive
- not easily reused
Answer: c.
- When should an operation contract be written?
- during analysis
- after coding
- at the same time as user documentation
- when taking initial notes from client
Answer: a.
- What information is included in the operation contract?
- the method’s interface
- data flow among the modules
- assumptions about input
- all of these
Answer: d.
- What kind of interface contains a method if and only that method is essential to that class’s
- complete
- minimal
responsibilities?
CHAPTER 01 2 / 4
Chapter 1 Questions © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
- expanded
- compact
Answer: b.
- What must be known about the ADT Bag in order to use it in a program?
- how entries in the bag are represented
- how bag operations are implemented
- how many entries can be stored in the bag
- the interface of the bag
Answer: d.
- According the CRC specifications for a Bag, which of the following behaviors would not be one of the
- See if the bag is empty
- See if the bag is full
- Look at all the objects in the bag
- Count the number of times a certain object occurs in the bag
responsibilities of the class Bag?
Answer: b.
- A client program depends solely on the ______ of the ADT.
- data members
- structure
- implementation
- behavior
Answer: d.
- What should a programmer do before implementing a recently designed class?
- write code that uses the class
- check comments that document specifications
- adjust the design when problems are discovered
- all of these
Answer: d
- Object-oriented programming views a program as ______.
- a sequence of actions
- a collection of classes
- a group of methods
- an interaction among objects
Answer: d.
- An ADT’s operations are known as its ______.
- axioms
- methods
- variables
- interfaces
Answer: b.
- Encapsulation combines an ADT’s data with its operations to form a(n) ______.
- exception
- method
- object
- variable
Answer: c.
- A(n) ______ is a C++ construct that enables a programmer to define a new data type. 3 / 4
Chapter 1 Questions © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
- class
- method
- data field
- object
Answer: a.
- A C++ class contains data members and ______.
- clients
- interfaces
- methods
- data structures
Answer: c.
- A(n) ______ is an instance of a class.
- method
- data field
- interface
- object
Answer: d.
- A(n) ______ is a class that inherits the members of another class.
- base class
- superclass
- abstract class
- subclass
Answer: d.
- A function can indicate that an error has occurred by ______ an exception.
- throwing
- catching
- implementing
- declaring
Answer: a.
- To ______ an exception means to deal with the error condition.
- declare
- catch
- implement
- try
Answer: b.
- Which of the following are ways to address unusual situations?
- simply assume the invalid situation will never occur
- guess at the client’s intention
- return a value that signals a problem
- all of the above are options
Answer: d.
- For the method remove(anEntry) of the ADT Bag, what would be the output of the method?
- anEntry
- nothing
- true or false
- the previous position of anEntry in the bag
Answer: c
- / 4