Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
About Exam
easy Solved by 8 students

String Iteration Character Count

Mark
< Prev
Next >

What is the value of the variable result after the following code segment is executed?

String word = "COMPUTER";
int result = 0;
for (int i = 0; i < word.length(); i++) {
    if (word.substring(i, i + 1).equals("E") || 
        word.substring(i, i + 1).equals("U")) {
        result++;
    }
}
A

2

B

1

C

0

D

3

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1sgarv251311 0m 00s 100
#2hitrishabhatia12 0m 00s 90
#3Pelisx11 0m 21s 79
#4busemagngr11 0m 22s 78
#5y.seong202712 1m 50s -20
#6yuvansankarnyc11 2m 22s -42
#7midnightasdark01 1m 06s -76
#8suhanakochhar00611 2m 58s -78
#9bommasam00011 56m 15s -3,275
Items per page:
10
1 – 9 of 9

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|