Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

AP CSA Question of the Day Jan. 31, 2025

Reference
  1. Incorrect Correct No Answer was selected Invalid Answer

    Given the following code segment, what will the output be?

    ArrayList<Integer> list = new ArrayList<Integer>();
    
    list.add(5);
    list.add(8);
    list.add(1);
    list.add(4);
    list.add(3);
    
    int counter = 0;
    
    while(counter < list.size()) {
        if (list.get(counter) % 2 == 0){
            list.set(counter, 0);
        }
        counter++;
    }
    System.out.println(list.toString());
    Java