4. Data Collections

Array Creation And Access — Quiz

Test your understanding of array creation and access with 5 practice questions.

Read the lesson first

Practice Questions

Question 1

In Java, what is the correct way to create an array of $5$ integers?

Question 2

If $int[] scores = new int[4];$, what is the value of $scores[0]$ before any assignment is made?

Question 3

For the array $int[] nums = {3, 7, 9, 12};$, what is the value of $nums[2]$?

Question 4

What does the expression $nums.length$ return for the array $int[] nums = {5, 8, 11};$?

Question 5

Which loop is best for visiting every element in an array from first to last?