Multiple Choice
The method below generates all substrings of a String passed as argument. Assuming that the string contains no duplicate characters, select the statement to complete the method so that it prints all substrings correctly. public static void printSubstrings(String word)
{
If (word.length() > 0)
{
For (int j = 1; j <= word.length() ; j++) // print substrings that begin
{ // with the first character
System.out.println(word.substring(0, j) ) ;
}
___________________________________ // print substrings without
} // the first character
}
A) printSubstrings(word.substring(0) ) ;
B) printSubstrings(word.substring(1) ) ;
C) printSubstrings(word.substring(word.length() ) ) ;
D) printSubstrings(word.substring(word.length() - 1) ) ;
Correct Answer:

Verified
Correct Answer:
Verified
Q25: Complete the code for the myFactorial recursive
Q26: A palindrome is a word or phrase
Q27: Consider the recursive version of the fib
Q28: Consider the method powerOfTwo shown below: public
Q29: In recursion, the non-recursive case is analogous
Q31: If recursion does not have a special
Q32: Consider the getArea method from the textbook
Q33: Would switching the special case order affect
Q34: Given the following code snippet: public static
Q35: Consider the getArea method from the textbook