CJCoding With Joseph
15free / daySign inCreate account
Back to Multiple Choice Quiz

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics

Count Letter A

Java quiz · Question 14
mediumLoops

What does this code output?

Code

1String str = "Java is amazing";
2int count = 0;
3for (int i = 0; i < str.length(); i++) {
4 if (str.charAt(i) == 'a') {
5 count++;
6 }
7}
8System.out.println(count);