Last Updated: January 3, 2026
31 quizzes
Access the last element of the scores array using its length
int lastScore = scores[ - 1];Click an option to fill the blank:
Quickly create an int array with three default-initialized elements
int[] values = int[3];Click an option to fill the blank:
Fill the monthlySales array with zeros in a single statement
java.util.Arrays.(monthlySales, 0);Click an option to fill the blank:
Which declaration correctly creates an array that can hold 10 double temperature readings?
What happens if you access numbers[5] in an int[] numbers = new int[5]; array?
Which operation is a typical use case for a linear search on an array?
For binary search on an int[] using your own implementation, what must be true?
How do you access the number of rows in a 2D int[][] matrix?
In a jagged int[][] arr, what does arr[1].length represent?
Which Arrays class method converts an int[] to a readable String?
Which method would you use to copy only the first 3 elements of an int[] source into a new int[]?
What is a key advantage of System.arraycopy over manual copying in a loop?
Which statement about Arrays.equals(int[], int[]) is correct?
Why might you create a copy of an int[] before sorting it?
Order the steps to search for a username in a sorted String[] using binary search you implement yourself.
Drag and drop to reorder, or use the arrows.
Order the steps to create and use a 2D int array for a game board.
Drag and drop to reorder, or use the arrows.
What is the output of this code?
1int[] scores = {10, 20, 30, 40};
2int index = 1;
3int result = scores[index] + scores[index + 2];
4System.out.println(result);What is the output of this code?
1int[][] grid = {
2 {1, 2},
3 {3, 4}
4};
5int value = grid[0][1] * grid[1][0];
6System.out.println(value);What is the output of this code?
1int[] data = {5, 3, 9, 1};
2java.util.Arrays.sort(data);
3System.out.println(data[0] + ":" + data[data.length - 1]);What is the output of this code?
1int[] original = {2, 4, 6};
2int[] copy = java.util.Arrays.copyOf(original, 2);
3copy[0] = 10;
4System.out.println(original[0] + "," + copy[0]);What is the output of this code?
1int[] a = {1, 2, 3};
2int[] b = a;
3b[1] = 99;
4System.out.println(a[0] + a[1] + a[2]);Find the bug in this code that initializes and prints a 2D array of seats.
Click on the line(s) that contain the bug.
public class Theater { public static void main(String[] args) { int[][] seats = new int[3][]; for (int row = 0; row < seats.length; row++) { for (int col = 0; col < seats[row].length; col++) { seats[row][col] = row + col; } } System.out.println(seats[0][0]); }}Find the bug in this code that copies sales data into a larger array.
Click on the line(s) that contain the bug.
public class SalesCopy { public static void main(String[] args) { int[] monthly = {10, 20, 30}; int[] yearly = new int[12]; System.arraycopy(yearly, 0, monthly, 0, monthly.length); System.out.println(java.util.Arrays.toString(yearly)); }}Match each Arrays class method with its primary purpose.
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Match the array-related concept with its best description.
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Complete the code to create a copy of an int array and sort the copy without changing the original.
int[] original = {5, 2, 9, 1};int[] = java.util.Arrays.copyOf(original, original.);java.util.Arrays.();System.out.println(java.util.Arrays.toString());Click an option to fill blank 1:
Complete the code to create and use a 2D int array for storing pixel brightness values.
int[][] pixels = new int[][];pixels[0][0] = 255;System.out.println(pixels. + "x" + pixels[0].);Click an option to fill blank 1:
Complete the code to perform a linear search on an int array for a target value.
int[] nums = {3, 7, 9, 2};int target = 9;int foundIndex = -1;for (int i = 0; i < nums.; i++) { if (nums[i] == ) { foundIndex = i; break; }}System.out.println(foundIndex);Click an option to fill blank 1:
Complete the code to copy part of an int array using System.arraycopy.
int[] source = {1, 2, 3, 4, 5};int[] dest = new int[3];System.(source, 1, dest, 0, );System.out.println(java.util.Arrays.toString(dest));Click an option to fill blank 1:
Click the line that will cause an ArrayIndexOutOfBoundsException at runtime.
Click on the line to select.
int[] values = new int[3];values[0] = 10;values[2] = 30;int x = values[3];System.out.println(x);Click the line that will throw a NullPointerException when executed.
Click on the line to select.
int[][] data = new int[2][];data[0] = new int[3];int sum = data[1][0];System.out.println(sum);