| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
About Exam
easy Solved by 7 students
String Iteration Character Count
< 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

1

B

0

C

3

D

2

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1sgarv251311 0m 00s 100
#2hitrishabhatia12 0m 00s 90
#3Pelisx11 0m 21s 79
#4y.seong202712 1m 50s -20
#5midnightasdark01 1m 06s -76
#6suhanakochhar00611 2m 58s -78
#7bommasam00011 56m 15s -3,275
Items per page:
10
1 – 7 of 7
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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