Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Practice Questions

Work through AP Computer Science A practice questions on Data Collections, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Subtopic: Arraylists Clear filter

Questions 11–20 of 225
  1. 11
  2. 12
  3. 13
  4. 14
  5. 15
  6. 16
  7. 17
  8. 18
  9. 19
  10. 20

Question 11

Multiple choice Arraylists
Consider the following code segment. List<String> list = new ArrayList<String>(); list.add("a"); list.add("b"); list.set(1, "c");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 12

Multiple choice Arraylists
Consider the following method. public ArrayList<Integer> mystery(int n) { ArrayList<Integer> seq = new ArrayList<Integer>(); for (int k = 1; k <= n; k++)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 13

Multiple choice Arraylists
Consider the following instance variable and method. private List<String> animals; public void manipulate() { for (int k = animals.size() - 1; k > 0; k--) { if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 14

Multiple choice Arraylists
Which of these methods will properly traverse two ArrayLists…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 15

Free response Arraylists
The factory keeps track of its printing machines in array machines, and it keeps track of its paper supply in two lists: newRolls to hold fresh rolls and…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 16

Multiple choice Arraylists
Consider the following code segment. ArrayList<String> words = new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 17

Multiple choice Arraylists
The two versions of the search method shown below are both intended to return true if ArrayList<Object> list contains the target value; otherwise they are…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 18

Multiple choice Arraylists
What is the outcome when the following code is compiled/executed? ArrayList<Integer> numbers = new ArrayList<Integer>();…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 19

Multiple choice Arraylists
Consider the following code segment. ArrayList<Integer> list = new ArrayList<Integer>(); list.add(1); list.add(2); for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 20

Multiple choice Arraylists
How do you create an…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 11 of 225
Page 2 of 23