Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

AP CSA Question of the Day Dec. 19, 2024

Reference
  1. Incorrect Correct No Answer was selected Invalid Answer

    Consider the following method

    public static void jumpAndHop(String word) {
        int i = 0;
        while(i < word.length() - 1) {
            String letter = word.substring(i, i + 1);
            if (letter.equals("m")) {
                i += 2;
            } else if (letter.equals("i")) {
                i += 3;
            }
            i++;
        } 
    }
    Java

    How many times does the loop execute when the following statement is executed?

    jumpAndHop("metamorphism");
    Java