NEW
Font size
WorksheetsCodeHS Arrays
Total questions: 18
Worksheet time: 9mins
What is the process of looping through every element in an array?
iterating over the array
looping over the array
implementing over the array
stringing over the array
What does this code do?
adds 1 to each element of the array
finds the sum of the array
prints the array to the screen and ends
throws an exception
What does this code do?
adds 1 to each element of the array
finds the sum of the array
prints the array to the screen and ends
throws an exception
What is first index value of an array?
-1
0
1
undefine
What is the length of this array?
Which definition below best describe an array?
An array is a function identifier that can hold more than one parameter.
An array is a beam of light.
An array is a special variable, which can hold more than one value at a time.
An array is a special function, which can hold more than one value at a time.
ar, given the following declaration:int[] ar = {2, 4, 6, 8 }0, 1, 2, 31, 2, 3, 40, 2, 4, 6I – A to-do list
II – A grocery list
III – A ball in a game of breakout
IV – A list of balls in a game of breakout
V – A loop counter variable
System.out.println("Number: " + numArray[2]);
System.out.println("Number: " + numArray[0]);
System.out.println("Number: " + numArray[numArray.length - 1]);
System.out.println(numArray.length);
In the following code segment, assume that the string str has been properly declared and initialized. The code segment is intended to print the number of strings in the array animals that have str as a substring. The code segment does not work as intended. Which of the following changes should be made so the code segment works as intended?
The Boolean expression in the for loop header should be changed to i < animals.length.
The Boolean expression in the for loop header should be changed to i < animals.length - 1.
The Boolean expression in the for loop header should be changed to i < animals[i].length.
The condition in the if statement should be changed to animals[i].equals(str).
The condition in the if statement should be changed to animals[i].substring(str).
Consider the following code segment. Which of the following represents the contents of the array arr after the code segment is executed?
{0, 1, 2, 3, 4, 5, 6}
{1, 1, 1, 1, 1, 1, 1}
{1, 1, 3, 3, 5, 5, 7}
{1, 2, 3, 4, 5, 6, 7}
{2, 2, 4, 4, 6, 6, 7}
