Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

AP CSA Question of the Day Jan. 28, 2025

Reference
  1. Incorrect Correct No Answer was selected Invalid Answer

    What will the contents of the ArrayList cities be as a result of running the following segment of code?
    Assume that the ArrayList cities has been instantiated and initialized to:
    ["Boston", "New York", "Boise", "Chicago", "Kansas City", "Baltimore"]

    for (int k = cities.size() - 1; k >= 0; k--)
    {
        if (cities.get(k).substring(0, 1).equals("B"))
        {
            cities.remove(k);
        }
    }
    Java