Absolute Java 5th Edition By Walter Savitch – Test Bank
Chapter 11
Recursion
Multiple Choice
1) A recursive method is one that:
(a) Returns a value
(b) Initializes a set of variables
(c) Returns no value
(d) Invokes itself
Answer: D
2) All recursive methods must have a/an:
(a) starting case
(b) intermediate case
(c) stopping case
(d) none of the above
Answer: C
3) Pick the best answer
(a) Recursive methods may include a recursive call
(b) Recursive methods may not use iteration
(c) Recursive methods must include a recursive call
(d) none of the above
Answer: C
4) Recursion is:
(a) the ability of a program to call itself
(b) the ability of a method to call itself
(c) the ability of a method to call smaller methods
(d) the ability of a method to implement factorials
Answer: B
5) Regarding recursion, if a base case is never reached the result is:
(a) infinite recursion
(b) iteration
(c) termination
(d) all of the above
Answer: A
6) Infinite recursion:
(a) will happen when there is no base case
(b) will not happen when there is a base case
(c) will not happen if we use subproblems
(d) none of the above
Answer: A
7) The underlying data structure used by the computer during recursion is a:
(a) queue
(b) linked list
(c) tree
(d) stack
Answer: D
8) The stack is a ________________ data structure.
(a) first in – first out
(b) last in – last out
(c) last in – first out
(d) none of the above
Answer: C
9) The portion of memory in which a recursive computation is stored is called a/an:
(a) stack frame
(b) activation record
(c) all of the above
(d) none of the above
Answer: C
10) During recursion, if the stack attempts to grow beyond its limit, a _____________ occurs.
(a) Stack underflow
(b) Stack overflow
(c) Recursive underflow
(d) Recursive overflow
Answer: B
11) A recursive solution can be preferable to an iterative solution because:
(a) recursive method calls are faster than iterative looping
(b) recursive solutions may be easier to understand than iterative ones
(c) recursion uses less memory than iteration
(d) iteration should be avoided.
Answer: B
12) All recursive methods have a/an ____________ equivalent method.
(a) Iterative
(b) Selective
(c) Inherited
(d) None of the above
Answer: A
Reviews
There are no reviews yet.