AP Computer Science a · Question of the Day

AP Computer Science a Question of the Day

A fresh daily question to build accuracy, reinforce recall, and turn practice into a steady habit.
Monday, August 24, 2026

public class Rotator { /** Precondition: list.size() > 0 */ public static void rotateRight(ArrayList list) { Integer last = list.remove(list.size() - 1); list.add(0, last); } }

An ArrayList named data contains [10, 20, 30, 40, 50]. What are the contents of data after the call Rotator.rotateRight(data)?

Keep practicing AP Computer Science a

Question of the Day

Answer today's AP Computer Science a question, reveal the full explanation, then keep the streak going with a new question every day.

public class Rotator { /** Precondition: list.size() > 0 */ public static void rotateRight(ArrayList list) { Integer last = list.remove(list.size() - 1); list.add(0, last); } }

An ArrayList named data contains [10, 20, 30, 40, 50]. What are the contents of data after the call Rotator.rotateRight(data)?

  1. [20, 30, 40, 50, 10]
  2. [10, 20, 30, 40]
  3. [50, 10, 20, 30, 40] (correct answer)
  4. [50, 20, 30, 40, 10]

Explanation: The method performs a right rotation. The last element (50) is removed from the end of the list, which becomes [10, 20, 30, 40]. Then, the removed element (50) is inserted at index 0. The final state of the list is [50, 10, 20, 30, 40].