Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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 1–10 of 173
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10

Question 1

Multiple choice Arraylists
Consider the following code segment. ArrayList<Integer> numList = new ArrayList<Integer>(); numList.add(3);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2

Multiple choice Arraylists
The following method is intended to remove all elements of an ArrayList of integers that are divisible by key and add the removed elements to a new ArrayList,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3

Multiple choice Arraylists
Consider the following class definition. public class Value { private int num; public int getNum() { return num; } // There may be instance variables,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 4

Multiple choice Arraylists
Consider the following instance variable and method. Method wordsWithCommas is intended to return a string containing all the words in listOfWords separated by…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 5

Multiple choice Arraylists
Consider the following code segment. List<String> students = new ArrayList<String>(); students.add("Alex"); students.add("Bob"); students.add("Carl"); for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 6

Multiple choice Arraylists
Consider the following code segment. ArrayList<String> items = new ArrayList<String>(); items.add("A"); items.add("B"); items.add("C");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 7

Multiple choice Arraylists
Consider the following method that is intended to modify its parameter nameList by replacing all occurrences of name with newValue. public void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 8

Multiple choice Arraylists
Consider the following declaration of the class NumSequence, which has a constructor that is intended to initialize the instance variable seq to an ArrayList of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 9

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 10

Multiple choice Arraylists
Consider the following field and method declarations. private List list; public void mystery(int n) { for (int i = 0; i Assume that list has been…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1 of 173
Page 1 of 18