Unit 4 Cycle 2 Day 1: Array Initialization

Unit 4, Data Collections • Cycle 2
Day 1 Advanced Practice • Harder Difficulty
Focus: Array Initialization Hard Array Initialization

Advanced Practice Question

Format: Array Initialization

What is the output?
int[] arr = new int[5];
arr[0] = 10;
arr[2] = 20;
System.out.println(arr[1] + arr[2] + arr[4]);
Difficulty: Hard  |  Topic: Array Initialization  |  Cycle: 2 (Advanced)
Why This Answer?

Uninitialized int array elements default to 0. arr[1]=0, arr[2]=20, arr[4]=0. Sum = 0+20+0 = 20.

Common Mistake
Watch Out!

Thinking uninitialized array elements are undefined or cause errors.

AP Exam Strategy

Arrays auto-initialize: int=0, double=0.0, boolean=false, objects=null.

Master This Topic

This Cycle 2 HARD question tests array initialization. Review Unit 4 concepts to build mastery of data collections.

  • Understanding array initialization
  • Tracing code execution accurately
  • Avoiding common pitfalls
View Unit 4 Study Guide

Ready for More Challenges?

Cycle 2 questions prepare you for the hardest AP CSA exam questions.

Study Games Practice FRQs
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.