What is the ArrayList nums if it is initially [5, 3, 1] and the following code is executed?
nums.add(6);
nums.add(0, 4);
nums.remove(1);
Java ArrayLists
Quiz
•
Computers
•
10th Grade
•
Medium
Used 857+ times
FREE Resource
11 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the ArrayList nums if it is initially [5, 3, 1] and the following code is executed?
nums.add(6);
nums.add(0, 4);
nums.remove(1);
[4, 3, 1, 6]
[5, 3, 1, 6]
[4, 3, 6]
[4, 5, 3, 6]
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What index value is used to locate the last element in the nums ArrayList?
nums.size()-1
nums.length()-1
nums.size()
nums.length
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which statement below is the correct way to retrieve the first element in the nums ArrayList?
nums.get(0)
nums[0]
nums(0)
nums[1]
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Given the ArrayList nums with the values [3, 7, 6, 0], what code below is the proper way to change the 7 to be a 5?
nums.set(1, 5)
nums.set(7, 5)
nums.set(5, 2)
nums[2] = 5
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Given the nums ArrayList with the values [5, 4, 3, 2], what statement below removes the value 3 from the list?
nums.remove(2)
nums.remove(3)
nums.get(2) = null
nums.remove(1)
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Given the nums ArrayList with the values [1, 2, 3, 4, 6], what code below can be used to add a 5 between the 4 and 6 in the list?
nums.add(4, 5)
nums.add(5, 4)
nums.add(5, 5)
nums.add(5)
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will print when the following code executes?
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(7);
list.add(8);
list.add(9);
System.out.println(list.remove(0));
7
8
9
0
10 questions
GCSE Computing: 2.2 Data Structures #1
Quiz
•
10th - 11th Grade
10 questions
mod 3 quiz
Quiz
•
9th - 12th Grade
12 questions
Python set
Quiz
•
10th Grade
11 questions
Javascript Lists Lecture Knowledge Check
Quiz
•
9th - 12th Grade
15 questions
Area With Arrays
Quiz
•
10th - 12th Grade
14 questions
List Review Quiz
Quiz
•
9th - 12th Grade
15 questions
APCS Lesson 7.0-7.2 Review
Quiz
•
9th - 12th Grade
10 questions
AP CS A Unit 7 Quiz PRACTICE
Quiz
•
9th - 12th Grade
15 questions
Multiplication Facts
Quiz
•
4th Grade
25 questions
SS Combined Advisory Quiz
Quiz
•
6th - 8th Grade
40 questions
Week 4 Student In Class Practice Set
Quiz
•
9th - 12th Grade
40 questions
SOL: ILE DNA Tech, Gen, Evol 2025
Quiz
•
9th - 12th Grade
20 questions
NC Universities (R2H)
Quiz
•
9th - 12th Grade
15 questions
June Review Quiz
Quiz
•
Professional Development
20 questions
Congruent and Similar Triangles
Quiz
•
8th Grade
25 questions
Triangle Inequalities
Quiz
•
10th - 12th Grade
40 questions
Week 4 Student In Class Practice Set
Quiz
•
9th - 12th Grade
40 questions
SOL: ILE DNA Tech, Gen, Evol 2025
Quiz
•
9th - 12th Grade
20 questions
NC Universities (R2H)
Quiz
•
9th - 12th Grade
25 questions
Triangle Inequalities
Quiz
•
10th - 12th Grade
46 questions
Biology Semester 1 Review
Quiz
•
10th Grade
65 questions
MegaQuiz v2 2025
Quiz
•
9th - 12th Grade
10 questions
GPA Lesson
Lesson
•
9th - 12th Grade
15 questions
SMART Goals
Quiz
•
8th - 12th Grade