
ArrayList Quiz
Quiz
•
Computers
•
12th Grade
•
Hard
brent hopkins
Used 3+ times
FREE Resource
16 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment.
ArrayList
[100, 300, 400]
[200, 300]
[200, 400]
Nothing is printed because the code segment does not compile.
Nothing is printed because an IndexOutOfBoundsException will occur.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following method countNegatives, which searches an ArrayList of Integer objects and returns the number of elements in the list that are less than 0.
public static int countNegatives(ArrayList
It has no impact on the behavior of the method.
It causes the method to ignore the last element in arr.
It causes the method to throw an IndexOutOfBoundsException.
It reduces the size of arr by 1 and the last element will be removed.
It changes the number of times the loop executes, but all indexes in arr will still be accessed.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following method findValue, which takes an ArrayList of String elements and a String value as parameters and returns true if the String value is found in the list and false otherwise.
public static boolean findValue(ArrayList
It has no impact on the behavior of the method.
It will cause the method to return a different result when the key value is not in the list.
It will cause the method to return a different result when the key value is found only at the first index in the list.
It will cause the method to return a different result when the key value is found only at the last index in the list.
It will cause the method to throw an array index out of bounds exception.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following method, inCommon, which takes two Integer ArrayList parameters. The method returns true if the same integer value appears in both lists at least one time, and false otherwise.
public static boolean inCommon(ArrayList
It has no impact on the behavior of the method.
It will cause the method to return a different result when the common value is not in the list.
It will cause the method to return a different result when the common value is found only at the first index in the list.
It will cause the method to return a different result when the common value is found only at the last index in the list.
It will cause the method to throw an array index out of bounds exception.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is printed as a result of executing the code segment?
Alex Alex Alex
Alex Alex Alex Alex Bob Carl
Alex Bob Carl Alex Alex Alex
Alex Bob Carl Alex Bob Carl
Nothing is printed because the first print statement will cause a runtime exception to be thrown.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In the following code segment, assume that the ArrayList wordList has been initialized to contain the String values ["apple", "banana", "coconut", "lemon", "orange", "pear"]. int count = 0; for (String word : wordList) { if (word.indexOf("a") >= 0) { count++; } } System.out.println(count); What is printed as a result of executing the code segment?
1
2
3
4
5
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following method, remDups, which is intended to remove duplicate consecutive elements from nums, an ArrayList of integers. For example, if nums contains [1, 2, 2, 3, 4, 3, 5, 6], then after executing remDups(nums), nums should contain [1, 2, 3, 4, 3, 5, 6].
public static void remDups(ArrayList
[1, 1, 2, 3, 3, 4, 5]
[1, 2, 2, 3, 3, 4, 5]
[1, 2, 2, 3, 4, 4, 5]
[1, 2, 2, 3, 4, 5, 5]
[1, 2, 3, 3, 4, 5, 5]
Create a free account and access millions of resources
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
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
16 questions
QUIZ RPL 3 ke 2
Quiz
•
12th Grade
13 questions
Dojo - Type Inference
Quiz
•
1st - 12th Grade
14 questions
Arrays, lists, tuples, stacks and queues
Quiz
•
11th - 12th Grade
15 questions
2D Lists and Arrays
Quiz
•
10th - 12th Grade
12 questions
Javascript Arrays
Quiz
•
9th - 12th Grade
20 questions
JDVP Activity
Quiz
•
12th Grade - University
20 questions
Java, part I
Quiz
•
11th Grade - University
20 questions
APCS A - Array 6.1,6.2,6.3,6.
Quiz
•
9th - 12th Grade
Popular Resources on Wayground
20 questions
Brand Labels
Quiz
•
5th - 12th Grade
10 questions
Ice Breaker Trivia: Food from Around the World
Quiz
•
3rd - 12th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
20 questions
ELA Advisory Review
Quiz
•
7th Grade
15 questions
Subtracting Integers
Quiz
•
7th Grade
22 questions
Adding Integers
Quiz
•
6th Grade
10 questions
Multiplication and Division Unknowns
Quiz
•
3rd Grade
10 questions
Exploring Digital Citizenship Essentials
Interactive video
•
6th - 10th Grade