14) What will the following code do? Assume s is a String, x is an int initialized to 10, page is a
Graphics object, and this is part of a paint method for an applet.
boolean isVowel = false;
String vowels = “aeiou”;
for (int j = 0; j < s.length( ); j++)
{
for (int k = 0; k < 5; k++)
if (s.charAt(j) == vowels.charAt(k)) isVowel = true;
if (isVowel) page.drawString(“”+s.charAt(j), 10, 15*x++);
else page.drawString(“”+s.charAt(j), 110, 15*x++);
isVowel = false;
}
A) The String s is printed down the applet in two columns, alternating each letter
B) The String s is printed across the applet with vowels printed in one row and all other
characters printed in a row above the vowels
C) The String s is printed across the applet with vowels printed in one row and all other
characters printed in a row below the vowels
D) The String s is printed down the applet in two columns with vowels appearing in the left
column and all other characters in the right column
E) The String s is printed down the applet in two columns with vowels appearing in the right
column and all other characters in the left column
15) Which of the following statements are true about Java loops?
A) all three loop statements are functionally equivalent
B) while loops and do loops are essentially the same; but while loops always execute at least
once
C) if you know the number of times that a loop is to be performed, the best loop statement to use
is a while loop
D) loops may be replaced by an appropriate combination of if-else and switch statements
E) none of the above