Verityprep
Question Bank

AP® Computer Science A Multiple Choice Questions

Work through AP Computer Science A multiple-choice questions unit by unit, 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.

Questions 2,221–2,230 of 2,811
  1. 2221
  2. 2222
  3. 2223
  4. 2224
  5. 2225
  6. 2226
  7. 2227
  8. 2228
  9. 2229
  10. 2230

Question 2221

Multiple choice Unit 4: Data Collections
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 2222

Multiple choice Unit 4: Data Collections
Consider the following instance variable and method. private int[] nums; /** Precondition: nums contains int values in no particular order. */ public int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2223

Multiple choice Unit 4: Data Collections
Consider the following method. public int mystery(int n) { if (n == 0) return 0; else if (n % 2…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2224

Multiple choice Unit 4: Data Collections
A two-dimensional matrix mat with at least one row is initialized and will be traversed using…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2225

Multiple choice Unit 4: Data Collections
A class of 30 students rated their computer science teacher on a scale of 1 to 10 (1 means awful and 10 means outstanding). The responses array is a 30-element…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2226

Multiple choice Unit 4: Data Collections
Consider an array arr that is initialized with int values. The following code segment stores in count the number of positive values in arr. int count = 0, index…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2227

Multiple choice Unit 4: Data Collections
A square matrix is declared as int[][] mat = new int[SIZE][SIZE]; where SIZE is an appropriate integer constant. Consider the following method. public static…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2228

Multiple choice Unit 4: Data Collections
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 2229

Multiple choice Unit 4: Data Collections
Assume that a Book class has a compareTo method in which, if b1 and b2 are Book objects, b1.compareTo(b2) is a negative integer if b1 is less than b2, a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2230

Multiple choice Unit 4: Data Collections
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 2,221 of 2,811
Page 223 of 282