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 981–990 of 1,222
  1. 981
  2. 982
  3. 983
  4. 984
  5. 985
  6. 986
  7. 987
  8. 988
  9. 989
  10. 990

Question 981

Multiple choice Using Text Files
Assume the file data.txt contains: 5 7 3 public static int readNumbers() throws Exception { Scanner file = new Scanner(new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 982

Multiple choice Using Text Files
Assume the file data.txt contains: apple banana cat public static int countLines() throws Exception { Scanner file = new Scanner(new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 983

Multiple choice Using Text Files
Assume the file data.txt contains: dog cat bird public static int totalLength() throws Exception { Scanner file = new Scanner(new File("data.txt"));…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 984

Multiple choice Using Text Files
Assume the file data.txt contains: 1 2 3 4 5 public static int countNumbers() throws Exception { Scanner file = new Scanner(new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 985

Multiple choice Using Text Files
Assume the file data.txt contains: apple banana cat dog fish bird public static int count() throws Exception { Scanner file = new Scanner(new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 986

Multiple choice Using Text Files
Assume the file data.txt contains: 4 7 2 9 5 8 public static int count() throws Exception { Scanner file = new Scanner(new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 987

Multiple choice Using Text Files
public static int readNumber() throws Exception { Scanner file = new Scanner(new File("data.txt")); return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 988

Multiple choice Using Text Files
public static int readNumber() throws Exception { Scanner file = new Scanner(new File("missing.txt")); return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 989

Multiple choice Using Text Files
public static int count() throws Exception { Scanner file = new Scanner(new File("data.txt")); int count = 0; while (file.hasNextInt())…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 990

Multiple choice Recursion
Consider the following method: public static int recur(int n) { if (n <= 1) return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 981 of 1,222
Page 99 of 123