Problem of the Day
Friday, December 19, 2025
Problem:
The String Array students holds the names of a series of students who are seated in order in a single line in a classroom.
String[] students = {"Aaron", "Bobby", "Caroline", "Darlene"};... for example, represents four students seated left-to-right in the classroom.

A teacher want to make sure that he works with every student once before seeing any student twice. What does the following code segment do?
int i = 0;
while (true)
{
System.out.println("Work with " + students[i]);
i = (i + 1) % students.length;
}
- Goes through the list of students once from left-to-right
- Goes through the list of students once from right-to-left
- Repeatedly goes through the list of student from left-to-right
- Repeatedly goes through the list of students from right-to-left
The correct answer is c. The index variable i starts at 0, and is incremented repeatedly in the infinite while loop, with a modulo operator % that resets the index to 0 after reaching the end of the list.