Question: Regarding the JAVA language consider this recursive factorial method to answer questions. public int factorial(int x) { if (x > 1) return x * factorial

Regarding the JAVA language consider this recursive factorial method to answer questions.

public int factorial(int x) {

if (x > 1)

return x * factorial (x 1);

else

return 1;

}

1. What is returned if factorial(3) is called?

2.

What is returned if factorial(0) is called?

Select one:

0

1

2

nothing, factorial(0) causes infinite recursion

nothing, factorial(0) produces a run-time error

3. How many times is the factorial method invoked if originally called with factorial(5)? Include the original method call in your counting.

4. What condition defines the base case for this method?

Select one:

(x <= 0)

(x = = 1)

(x = = 0)

(x <= 1)

(x > 1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!