Font size
WorksheetsEnumeration and Recursion
Total questions: 12
Worksheet time: 6mins
Why do you need to use a base case?
So that the code loops forever
So that the code does not loop forever
To exit the recursive function
To call another function
Which of the following is the best definition of a recursive method?
A method that iterates itself exactly 5 times.
A method that invokes itself by name within the method.
A method that will never iterate infinitely.
A method that cannot be called more than once.
A program may run out of memory in a:
non-recursive function call
recursive function call
condition when too many variables are declared
none of the above
Which of the following condition is true?
Recursion is always better than iteration.
Recursion uses more memory as compared to iteration.
Recursion uses less memory as compared to iteration.
Iteration is always better and simpler than recursion.
Which of the following problems MAY be solved using recursion?
finding Nth number of the Fibonacci sequence
finding the factorial of a number
finding the length of a string
all of the above
Recursion is similar to which of the following?
if-else
switch-case
loops
none of the above
Which of the following algorithms use recursion?
Linear Search
Binary Search
Merge sort
Insertion sort
Which is faster and uses less memory?
Recursion
Iteratoration
Enumeration
ArrayLists
In Java, enum is a(n):
class
object
data type
interface
What would be the results for the following code block?
low
medium
high
HIGH
MEDUIM
LOW
LOW
MEDIUM
HIGH
LOW MEDIUM HIGH
Can enums have attributes and methods?
Yes
No
Once an enum is created, can a program change its values?
Yes
No
