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 921–930 of 1,222
  1. 921
  2. 922
  3. 923
  4. 924
  5. 925
  6. 926
  7. 927
  8. 928
  9. 929
  10. 930

Question 921

Multiple choice Arraylists
What is the output of the following? ArrayList<Integer> a = new ArrayList<>(); for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 922

Multiple choice Using Text Files
A file numbers.txt contains one integer per line. Which code segment correctly reads all integers and finds the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 923

Multiple choice 2D Arrays
A method receives a 2D array int[][] m where all rows have…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 924

Multiple choice Arrays
The following method is supposed to shift all elements of an array one position to the left, with the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 925

Free response Arraylists
A sensor produces a stream of numeric readings. Consider the following incomplete class: public class SensorLog { private ArrayList<Double> readings; public…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 926

Free response 2D Arrays
A board game uses a 2D integer array where each cell holds a point value. Consider: public class GameBoard { private int[][] board; // rows x cols public…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 927

Multiple choice Arraylists
What does list contain after the following loop? ArrayList<Integer> list = new ArrayList<Integer>(); list.add(3); list.add(1);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 928

Multiple choice 2D Arrays
What is printed? int[][] m = {{2,7,6}, {9,5,1}, {4,3,8}}; int sum = 0; for (int i = 0;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 929

Multiple choice Arrays
What does arr contain after the following code? int[] arr = {5, 2, 8, 1, 9, 3}; for (int i = 0; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 930

Multiple choice Arraylists
What is printed? ArrayList<String> words = new ArrayList<String>(); words.add("cat"); words.add("car"); words.add("dog"); words.add("care"); words.add("card");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 921 of 1,222
Page 93 of 123