What is the given recursive method doing please use a


1. What is the following recursive method doing? Please use a for-loop to implement the same task. public int mystery(int num)
{
int result;
if (num == 0)
result = 0;
else
result = num + mystery(num-1);
return result;
}

2. Suppose we create a subclass from a class that has a method called someMethod. If we override someMethod in the subclass, is it possible to access the superclass's version of someMethod? If so, how?

3. A method that calls itself is a __________________ method.
a.recursive
b.static
c.final
d.invalid

4. In a recursive solution, _______________ is(are) always necessary.
a.several variables
b.a base case
c.short, efficient code
d.numerous lines of code

5. What is the consequence of infinite recursion in Java?
a.The program will not compile.
b.The program will hang as though there is an infinite loop.
c.The program will not run
d.The program will throw an ArrayOutOfBoundsException.

6. In Java, array indexes always begin at ________________ .
a.1
b.0
c.-1
d.2

7. What will be the output of the following code snippet?
int[] array = new int[25];
System.out.println(array.length);
a.This code will result in a compile time error.
b.26
c.25
d.24

Solution Preview :

Prepared by a verified Expert
JAVA Programming: What is the given recursive method doing please use a
Reference No:- TGS02366560

Now Priced at $10 (50% Discount)

Recommended (98%)

Rated (4.3/5)