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 901–910 of 1,222
  1. 901
  2. 902
  3. 903
  4. 904
  5. 905
  6. 906
  7. 907
  8. 908
  9. 909
  10. 910

Question 901

Multiple choice Using Text Files
Consider the following code segment: public void readLines() { File myFile = new File("data.txt"); Scanner scanner = new Scanner(myFile); while…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 902

Multiple choice Using Text Files
Assume that info.txt contains the following: Hello World AP CSA Good Bye Consider the following code segment: File file = new File("info.txt"); Scanner scanner…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 903

Free response Arraylists
GPSRouter stores routes in an initialized ArrayList routes. Route provides String getName(), int getMiles(), and void setMiles(int num). The provided…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 904

Free response 2D Arrays
The High School Coin Collection Club needs new software to help organize its coin collections. Each coin in the collection is represented by an object of the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 905

Multiple choice Arraylists
What is the output of this code? ArrayList<String> words = new ArrayList<>();…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 906

Multiple choice 2D Arrays
What is the value of sum after the following executes? int[][] grid = { {1, 2, 3}, {4, 5,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 907

Multiple choice Arraylists
Consider traversing an ArrayList while removing elements. Which approach avoids skipping elements? // Approach I – forward traversal for (int i = 0; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 908

Multiple choice Arrays
Consider the following method: public static int[] doubleArray(int[] arr) { int[] result = new int[arr.length]; for (int i = 0; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 909

Multiple choice Arrays
What is the output of the following code? int[] arr = {5, 3, 8, 1, 9}; int result = arr[0]; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 910

Multiple choice Arraylists
Consider the following: ArrayList<Integer> list = new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 901 of 1,222
Page 91 of 123