Skip to main content

Java Topic Practice

String Traversal

String Traversal MCQ Practice

Question 1 of 15

Answered 0 of 15

Choose one answer.

What is printed by the following code segment?

String word = "ALGORITHM";
int count = 0;
for (int i = 0; i < word.length(); i++) {
  char c = word.charAt(i);
  if (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') count++;
}
System.out.print(count);
Choose one answer.