Skip to main content

Practice · 2 of 4

Exam MCQ

CHALLENGE
Difficulty: advanced+25 XP

What does this return for s = "aXbXc"? ``java public static int countAfter(String s, char first, char second) { int count = 0; for (int i = 1; i < s.length(); i++) { if (s.charAt(i - 1) == first && s.charAt(i) == second) { count++; } } return count; } ` Called as countAfter("aXbXc", 'X', 'b')`. A. 2 B. 1 C. 0 D. 3 Print the letter, then your one-sentence justification.

Back to lesson: Practice: Exam #3: MCQ section