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 71–80 of 173
  1. 71
  2. 72
  3. 73
  4. 74
  5. 75
  6. 76
  7. 77
  8. 78
  9. 79
  10. 80

Question 71

Multiple choice Arraylists
Consider the following instance variable and method. private ArrayList<Integer> nums; /** Precondition: nums.size > 0 */ public void numQuest() { int k = 0;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 72

Multiple choice Arraylists
Consider the following methods. public List<Integer> process1(int n) { List<Integer> someList = new ArrayList<Integer>(); for (int k = 0; k < n; k++)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 73

Multiple choice Arraylists
What is printed? Assume java.util.ArrayList has been imported. public class Java1102 { public static void main(String[] args) { ArrayList names=new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 74

Multiple choice Arraylists
Consider this program segment. You may assume that wordList has been declared as ArrayList<String>. for (String s :…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 75

Multiple choice Arraylists
Refer to the following declarations. String[] colors = {"red", "green", "black"}; ArrayList<String> colorList = new ArrayList<String>(); Which of the following…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 76

Multiple choice Arraylists
Refer to method removeWord. /** Removes all occurrences of word from wordList. /** Precondition: wordList is an ArrayList of String objects. * Postcondition:…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 77

Multiple choice Arraylists
Consider an ArrayList cards of Card objects that needs to be shuffled. The following algorithm is used for shuffling. Create a temporary ArrayList<Card> Do the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 78

Multiple choice Arraylists
Let list be an ArrayList<String> containing only these elements. "John", "Mary", "Harry", "Luis" Which of the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 79

Multiple choice Arraylists
Consider the following declaration. ArrayList<Integer> list = new ArrayList<Integer>(); Which of the following code segments will place the integers 1 to 10, in…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 80

Multiple choice Arraylists
Refer to the static method removeNegs shown below. /** Precondition: list is an ArrayList<Integer>. * Postcondition: All negative values have been removed from…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 71 of 173
Page 8 of 18