Consider the following paint method to answer the questions below:
public void paint(Graphics page)
{
int x, y = 200;
page.setColor(Color.blue) ;
for (x = 100; x < 200; x += 20)
page.fillRect(x, y, 10, y-x) ;
}
-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
Correct Answer:
Verified
Q2: The following loop is syntactically valid:
for(int j
Q14: The following for loop is an infinite
Q14: Given that s is a String, what
Q15: Control in a switch statement jumps to
Q16: You might choose to use a switch
Q17: Given the following code, where x =
Q20: It is possible to convert any type
Q21: Rewrite the following nested if-else statement as
Q22: How many times will the System.out.println(*); statement
Q24: Write a paint method to draw out
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents