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.

Questions 521–530 of 1,222
  1. 521
  2. 522
  3. 523
  4. 524
  5. 525
  6. 526
  7. 527
  8. 528
  9. 529
  10. 530

Question 521

Multiple choice Arrays
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 522

Multiple choice 2D Arrays
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 523

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 524

Multiple choice Arrays
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 525

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 526

Multiple choice Sorting And Searching
A sorted list of 120 integers is to be searched to determine whether the value 100 is in the list. Assuming…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 527

Multiple choice Sorting And Searching
Consider a sorted array arr of n elements, where n is large and n is even. Under which conditions will a sequential search of arr be faster…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 528

Multiple choice Arrays
Refer to the following data field and method. private int[] arr; /** Precondition: arr.length > 0 and index < arr.length. */ public void remove(int index) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 529

Multiple choice 2D Arrays
A matrix class that manipulates matrices contains the following declaration. private int[][] mat = new int[numRows][numCols]; Consider the following method that…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 530

Multiple choice Arrays
Consider an array arr that is sorted in increasing order, and method findMost given below. Method findMost is intended to find the value in the array that…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 521 of 1,222
Page 53 of 123