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.

Questions 421–430 of 1,079
  1. 421
  2. 422
  3. 423
  4. 424
  5. 425
  6. 426
  7. 427
  8. 428
  9. 429
  10. 430

Question 421

Multiple choice Arrays
Consider the following code segment. int [] ray = new int [11]; for (int i = 0; i < ray.length; i++) { ray[i] = i * 2; } for (int m = 0; m < 5;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 422

Multiple choice Sorting And Searching
Consider the following method. public void mystery (int[] array) { for (int i = 1; i < array.length; i++) { int j; int key = array[i]; for (j = i - 1; j >= 0 &&…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 423

Multiple choice Arraylists
Consider the following class declaration. public class City { private String name; private int population; public City(String myName, int myPop) { name =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 424

Multiple choice Arrays
Consider the following code segment. int[] myArray = {2, 3, 4, 1, 7, 6, 8}; int index = 0; while…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 425

Multiple choice Arraylists
Consider the following class used by a company to represent the items it has available for online purchase. public class OnlinePurchaseItem { public double…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 426

Multiple choice Recursion
Consider the following method. public int mystery(int n) { if (n <= 1) return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 427

Multiple choice Recursion
Consider the following method. public int guess(int num1, int num2) { if (num1 % num2 == 0) return (num2 + num1) / 2; return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 428

Multiple choice Arraylists
Consider the following code segment. String crazyString = "crazy"; ArrayList<String> crazyList = new ArrayList<String>(); crazyList.add("weird");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 429

Multiple choice Arrays
Assume int[] arr has been correctly instantiated and is of sufficient size. Which of these code segments results in identical arrays? I. int i = 1; while (i…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 430

Multiple choice Arraylists
Consider the following code segment. ArrayList<String> nations = new ArrayList<String>(); nations.add("Argentina"); nations.add("Canada");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 421 of 1,079
Page 43 of 108