Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

AP CSA Question of the Day May 2, 2025

Reference
  1. Incorrect Correct No Answer was selected Invalid Answer

    Fill in the missing code in the following code block to create an algorithm that makes all odd numbers in an ArrayList negative. Assume the ArrayList contains only positive numbers originally.

    ArrayList<Integer> array = new ArrayList<Integer>();
    array.add(1);
    array.add(2);
    ...
    
    for (int i = 0; i < array.size(); i++) {
        if (/* LINE 1 */) {
            array.set(/* LINE 2 */);
        }
    }
    Java