
Arrays and ArrayLists
Authored by Daniel Vega
Computers
10th - 12th Grade
Used 62+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code segment. Which of the following statements best describes the condition when it returns true? a is an integer array.
whenever the first element in a is equal to val
Whenever a contains any element which equals val
Whenever the last element in a is equal to val
Whenever more than 1 element in a is equal to val
Whenever exactly 1 element in a is equal to val
2.
MULTIPLE SELECT QUESTION
3 mins • 1 pt
Look at the following code segment. Which of the following arrays would return true when val = 4? Select all that apply.
a = {4, 3, 2, 1};
a = {1, 2, 3, 4};
a = {1, 2, 3, 4, 3, 2, 1};
a = {4, 4, 2, 2};
a = {2, 2, 2, 4};
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Look at the following code. What would findLargest(10) return?
2
3
5
7
13
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following field arr and method checkArray. Which of the following best describes what checkArray returns?
Returns the index of the largest value in array arr.
Returns the index of the first element in array arr whose value is greater than arr[loc].
Returns the index of the last element in array arr whose value is greater than arr[loc].
Returns the largest value in array arr.
Returns the index of the largest value in the second half of array arr.
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Given the following field and method declaration, what is the value in a[1] after m1(a) has run?
4
2
12
6
3
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Given the following code, what does m1(a) return?
4
2
12
6
3
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following method changeArray. An array is created that contains {2, 8, 10, 9, 6} and is passed to changeArray. What are the contents of the array after the changeArray method executes?
{2, 6, 2, -1, -3}
{-23, -21, -13, -3, 6}
{10, 18, 19, 15, 6}
This method results in an IndexOutOfBounds exception.
{35, 33, 25, 15, 6}
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?