Preview (3 of 9 pages)

Preview Extract

Chapter 9: Advanced Modularization Techniques
1. You can invoke or call a method from another program or method.
Answer: True
2. When methods must share data, you can pass the data into and return the data out of
Answer: True
3. A method could be called using any numeric value as an argument, whether it is a variable,
a named constant, or a literal constant.
Answer: True
4. A method’s return type is part of its signature.
Answer: False
5. A method’s declared return type must match the type of value used in the return statement.
Answer: True
6. Methods with identical names that have identical parameter lists but different return types
are ambiguous.
Answer: True
7. All modern programming languages contain many methods that are predefined.
Answer: True
8. In implementation hiding, the calling method needs to understand only the interface to the
method that is called and it need not know how the method works internally.
Answer: True
9. Most programmers consciously make decisions about cohesiveness for each method they
Answer: False
10. Programs that use recursion are error-prone but easy to debug.
Answer: False
1. The last statement in a method is a(n) ____.
a. begin statement
b. return statement
c. exit statement

d. end statement
Answer: B
2. Variables and constants are ____ within, or local to, only the method in which they are
a. in scope
b. out of bounds
c. out of scope
d. limited
Answer: A
3. When a data item is known to all of a program’s modules, it is a ____data item.
a. scope
b. defined
c. local
d. global
Answer: D
4. A calling method sends a(n) ____ to a called method.
a. parameter
b. interface
c. object
d. argument
Answer: D
5. A called method accepts the value of an argument passed to it as its ____.
a. parameter
b. reference
c. baseline
d. argument
Answer: A
6. A method’s name and parameter list constitute the method’s ____.
a. header
b. interface
c. contract

d. signature
Answer: D
7. You can think of the ____ in a method declaration as a funnel into the method.
a. braces
b. brackets
c. parentheses
d. commas
Answer: C
8. A variable usually is passed into a method by ____.
a. reference
b. inference
c. insinuation
d. value
Answer: D
9. Each time a method executes, any parameter variables listed in the method header are
a. examined
b. redeclared
c. referenced
d. copied
Answer: B
10. The variables in the method declaration that accept the values from the actual parameters
are ____ parameters.
a. defined
b. proper
c. formal
d. actual
Answer: C
11. A method can return nothing, in which case the method is a ____ method.
a. null
b. void

c. nul
d. nil
Answer: B
12. Programmers use the term ____ to describe any extra time and resources required by an
a. black box
b. overhead
c. overload
d. cohesion
Answer: B
13. ____ provide an overview of input to the method, the processing steps that must occur,
and the result.
a. Stacks
b. Hierarchy charts
c. IPO charts
d. Flowcharts
Answer: C
14. When multiple parameters appear in a method header, they constitute a(n) ____.
a. parameter list
b. input list
c. action list
d. variable list
Answer: A
15. Arrays, unlike simple built-in types, are passed by ____.
a. deference
b. value
c. reference
d. configuration
Answer: C
16. ____ is the ability of a method to act appropriately depending on the context.
a. Cohesion

b. Chameleon
c. Integrity
d. Polymorphism
Answer: D
17. When you ____ a method, you write multiple methods with a shared name but different
parameter lists.
a. stack
b. overload
c. overhead
d. void
Answer: B
18. Using implementation hiding means that the ____ is the only part of a method with which
the method’s client interacts.
a. argument list
b. interface to the method
c. parameter list
d. internal detail
Answer: B
19. ____ refers to how the internal statements of a method serve to accomplish the method’s
a. Coupling
b. Cohesion
c. Bonding
d. Binding
Answer: B
20. ____ is a measure of the strength of the connection between two program methods.
a. Coupling
b. Cohesion
c. Bonding
d. Binding
Answer: A

21. ____ occurs when methods excessively depend on each other and makes programs more
prone to errors.
a. Late coupling
b. Loose coupling
c. Tight coupling
d. Weak coupling
Answer: C
22. ____ occurs when methods do not depend on others.
a. Tight coupling
b. Loose coupling
c. Data coupling
d. Abstract coupling
Answer: B
23. ____ occurs when a method is defined in terms of itself.
a. Referential integrity
b. Repeatability
c. Dependence
d. Recursion
Answer: D
24. A method that calls itself is a ____.
a. recursive method
b. repeated method
c. self-referencing method
d. simple method
Answer: A
25. Every time you call a method, the address to which the program should return at the
completion of the method is stored in a memory location called the ____.
a. heap
b. queue
c. stack
d. dump

Answer: C
1. When a data item is known to all of a program’s modules, it is a(n)
____________________ data item.
Answer: global
2. When the method ends at the ____________________ statement, the locally declared
parameter variable ceases to exist.
Answer: return
3. A(n) ____________________ chart is a tool that identifies and categorizes each item
needed within the method as pertaining to input, processing, or output.
Answer: IPO
4. Programmers refer to hidden implementation details as existing in a(n)
Answer: black box
5. Using recursion successfully requires a thorough understanding of
Answer: looping
Match each term with a statement below.
1. A program module that contains a series of statements that carry out a task a. functionally
2. The declaration or definition b. passed by value
3. A copy of a variable’s value is sent to the method and stored in a new memory location
accessible to the method c. actual parameters
4. A new memory location is reserved and named d. loose coupling
5. The arguments sent to a method in a method call e. method
6. When the method receives the actual memory address of the array and has access to the
actual values in the array elements f. redeclared
7. The ability of a method to act appropriately according to the context g. passed by reference
8. When all the operations in a method contribute to the performance of a single task h.
method header
9. Occurs when methods have access to the same globally defined variables i. tight coupling

10. Occurs when a copy of data that must be shared is passed from one method to another j.
1. Answer: E
2. Answer: H
3. Answer: B
4. Answer: F
5. Answer: C
6. Answer: G
7. Answer: J
8. Answer: A
9. Answer: I
10. Answer: D
1. List the three things you need to know when you call a method from a program or other
Answer: • The name of the called method
• What type of information to send to the method, if any
• What type of return data to expect from the method, if any
2. List the items that must be included within the method declaration’s parentheses.
Answer: When you write the declaration for a method that can receive a parameter, you must
include the following items within the method declaration parentheses:
• The type of the parameter
• A local name for the parameter
3. Describe how you create and use a method with multiple parameters.
Answer: A method can require more than one parameter. You create and use a method with
multiple parameters by doing the following:
• You list the arguments within the method call, separated by commas.
• You list a data type and local identifier for each parameter within the method header’s
parentheses, separating each declaration with a comma.
4. Describe what a method’s return statement can return.
Answer: A method’s return statement can return one value at most. The value can be a simple
data type or it can be a more complex type—for example, a structure or an object.

5. List the four things that you need to know when you want to use a method.
Answer: • What the method does in general, but not necessarily how it carries out tasks
• The method’s name
• The method’s required parameters, if any
• The method’s return type, so that you can use any returned value appropriately
6. Discuss tight coupling.
Answer: Tight coupling occurs when methods have access to the same globally defined
variables. When one method changes the value stored in a variable, other methods are
affected. Because you should avoid tight coupling, all the examples in this book avoid using
global variables. However, be aware that you might see them used in programs written by
7. Discuss loose coupling.
Answer: Loose coupling occurs when a copy of data that must be shared is passed from one
method to another. That way, the sharing of data is always purposeful—variables must be
explicitly passed to and from methods that use them. The loosest (best) methods pass single
arguments rather than many variables or entire records, if possible.
8. Describe recursion.
Answer: Recursion occurs when a method is defined in terms of itself. A method that calls
itself is a recursive method. Some programming languages do not allow a method to call
itself, but those that do can be used to create recursive methods that produce interesting
9. Explain what happens when you call a method and the method ends.
Answer: Every time you call a method, the address to which the program should return at the
completion of the method is stored in a memory location called the stack. When a method
ends, the address is retrieved from the stack and the program returns to the location from
which the method call was made.
10. Discuss the cumulative summing relationship.
Answer: When thinking about cumulative summing relationships, remember that the sum of
all the integers up to and including any number is that number plus the sum of the integers for
the next lowest number. In other words, consider the following:
• The sum of the digits from 1, up to and including 1, is simply 1.
• The sum of the digits from 1 through 2 is the previous sum, plus 2.
• The sum of the digits from 1 through 3 is the previous sum, plus 3.
• The sum of the digits 1 through 4 is the previous sum, plus 4.
• And so on

Test Bank for Programming Logic and Design
Joyce Farrell
9781111969752, 9788131525906, 9781111825959

Document Details

Related Documents


Send listing report


You already reported this listing

The report is private and won't be shared with the owner


Send Message


My favorites


Application Form

Notifications visibility rotate_right Clear all Close close