45.1k views
3 votes
JAVA...Write a statement that calls the recursive method backwardsAlphabet() with parameter startingLetter.

CODE BELOW
public class RecursiveCalls {
public static void backwardsAlphabet(char currLetter) {
if (currLetter == 'a') {
System.out.println(currLetter);
}
else {
System.out.print(currLetter + " ");
backwardsAlphabet(--currLetter);
}
}
public static void main (String [] args) {
char startingLetter;
startingLetter = 'z';
/* Your solution goes here */
}
}

User Idov
by
4.6k points

1 Answer

4 votes

Answer:

RecursiveCalls.backwardsAlphabet(startingLetter);

Step-by-step explanation:

The statement that is needed is a single-line statement. Since the class RecursiveCalls is already in the same file we can simply use that class and call its function without making a new class object. Once we call that class' function we simply pass the variable startingLetter (which is already provided) as the sole parameter for the function in order for it to run and use the letter 'z' as the starting point.

RecursiveCalls.backwardsAlphabet(startingLetter);

User TheKalpit
by
4.9k points