Skip to main content

Java Topic Practice

ArrayList Traversal

Practice mode with 15 Java-focused questions, immediate answer checks, and explanations.

For practice use only.

ArrayList Traversal MCQ Practice

ArrayList Traversal Java practice with 15 questions, code tracing, and a worked explanation for every answer.

Question 1 of 15

Answered 0 of 15

Choose one answer.

Code Tracing 01 - ArrayList Traversal: track the final printed value.

import java.util.ArrayList;
public class Main {
  public static void main(String[] args) {
    ArrayList<Integer> nums = new ArrayList<Integer>();
    nums.add(3);
    nums.add(7);
    nums.add(3);
    nums.add(9);
    nums.add(5);
    int total = 0;
    for (int i = 0; i < nums.size(); i += 2) {
      total += nums.get(i);
    }
    System.out.print(total);
  }
}
Choose one answer.