What is the list nums if it is initially [5, 3, 1] and the following code is executed?
nums.add(6);
nums.add(0, 4);
nums.remove(1);
APCS A Java Arrays vs ArrayLists
Quiz
•
Other
•
10th - 12th Grade
•
Easy
John Schlamann
Used 9+ times
FREE Resource
23 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the list 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
30 sec • 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
30 sec • 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
30 sec • 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
30 sec • 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
30 sec • 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
30 sec • 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
20 questions
Arrays
Quiz
•
9th - 12th Grade
21 questions
AP CSP Unit 5 Review 2021
Quiz
•
12th Grade
20 questions
Demon Slayer
Quiz
•
12th Grade
20 questions
Archery Practice
Quiz
•
3rd Grade - Professio...
25 questions
ULANGAN INFORMATIKA KELAS X
Quiz
•
10th Grade
18 questions
Musical Instruments
Quiz
•
9th - 12th Grade
20 questions
UAS KOMPUTER AKUNTANSI (KELAS XI AKUNTANSI)
Quiz
•
11th Grade
20 questions
List Manipulations
Quiz
•
11th Grade
15 questions
Multiplication Facts
Quiz
•
4th Grade
20 questions
Math Review - Grade 6
Quiz
•
6th Grade
20 questions
math review
Quiz
•
4th Grade
5 questions
capitalization in sentences
Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions
Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines
Quiz
•
Professional Development
12 questions
Dividing Fractions
Quiz
•
6th Grade
25 questions
Spanish preterite verbs (irregular/changed)
Quiz
•
9th - 10th Grade
10 questions
Juneteenth: History and Significance
Interactive video
•
7th - 12th Grade
8 questions
"Keeping the City of Venice Afloat" - STAAR Bootcamp, Day 1
Quiz
•
9th - 12th Grade
20 questions
Distance, Midpoint, and Slope
Quiz
•
10th Grade
20 questions
Figurative Language Review
Quiz
•
10th Grade
20 questions
Understanding Linear Equations and Slopes
Quiz
•
9th - 12th Grade