
ArrayList Quiz
Quiz
•
Computers
•
12th Grade
•
Practice Problem
•
Hard
brent hopkins
Used 3+ times
FREE Resource
Enhance your content in a minute
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]
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?
Similar Resources on Wayground
20 questions
Python Recap
Quiz
•
7th Grade - University
15 questions
Mengenal Internet dan Jaringan Local
Quiz
•
12th Grade
15 questions
Vocabulary of Computer
Quiz
•
12th Grade
15 questions
Lua Review Corona SDK with Notepad++
Quiz
•
10th - 12th Grade
15 questions
Asesmen Sumatif
Quiz
•
12th Grade
14 questions
ISTQB FOUNDATION 4.0 | Tutorial 41
Quiz
•
12th Grade
15 questions
History of Computers
Quiz
•
6th - 12th Grade
16 questions
Python Basics
Quiz
•
KG - University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
