wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Enumeration and Recursion

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

Why do you need to use a base case?

a)

So that the code loops forever

b)

So that the code does not loop forever

c)

To exit the recursive function

d)

To call another function

2.

Which of the following is the best definition of a recursive method?

a)

A method that iterates itself exactly 5 times.

b)

A method that invokes itself by name within the method.

c)

A method that will never iterate infinitely.

d)

A method that cannot be called more than once.

3.

A program may run out of memory in a:

a)

non-recursive function call

b)

recursive function call

c)

condition when too many variables are declared

d)

none of the above

4.

Which of the following condition is true?

a)

Recursion is always better than iteration.

b)

Recursion uses more memory as compared to iteration.

c)

Recursion uses less memory as compared to iteration.

d)

Iteration is always better and simpler than recursion.

5.

Which of the following problems MAY be solved using recursion?

a)

finding Nth number of the Fibonacci sequence

b)

finding the factorial of a number

c)

finding the length of a string

d)

all of the above

6.

Recursion is similar to which of the following?

a)

if-else

b)

switch-case

c)

loops

d)

none of the above

7.

Which of the following algorithms use recursion?

a)

Linear Search

b)

Binary Search

c)

Merge sort

d)

Insertion sort

8.

Which is faster and uses less memory?

a)

Recursion

b)

Iteratoration

c)

Enumeration

d)

ArrayLists

9.

In Java, enum is a(n):

a)

class

b)

object

c)

data type

d)

interface

10.

What would be the results for the following code block?

a)

low

medium

high

b)

HIGH

MEDUIM

LOW

c)

LOW

MEDIUM

HIGH

d)

LOW MEDIUM HIGH

11.

Can enums have attributes and methods?

a)

Yes

b)

No

12.

Once an enum is created, can a program change its values?

a)

Yes

b)

No