AP Computer Science A Quiz
20 questions · no time limit
0:00
SELECTION AND ITERATION
Question 1 of 20
No time limit
Current
Answered
Flagged
Not seen
A student is comparing each pair of names to find matching first letters. Consider the following Java code.
String[] names = {"Ava", "Ben", "Amy"};
int matches = 0;
for (int i = 0; i < names.length; i++) {
for (int j = i + 1; j < names.length; j++) {
if (names[i].charAt(0) == names[j].charAt(0)) {
matches++;
}
}
}
System.out.println(matches);What is the output of the following nested loop? YOUR PROGRESS
20
QUESTIONS
Ready when you are
Answer in any order. Your progress shows here as you go.
QUESTIONS
KEYBOARD
Pick an answer ABCD
Next question ↵→
Previous ←
Flag for review F
Answers save as you go · flagged questions come back at the end