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.

Subtopic: Recursion Clear filter

Questions 21–30 of 140
  1. 21
  2. 22
  3. 23
  4. 24
  5. 25
  6. 26
  7. 27
  8. 28
  9. 29
  10. 30

Question 21

Multiple choice Recursion
Consider the following recursive method. public static void whatsItDo(String str) { int len = str.length(); if (len > 1) { String temp…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 22

Multiple choice Recursion
Consider the following recursive method. public static void printSomething(int n) { if (n…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 23

Multiple choice Recursion
Consider the following recursive function: public int mystery(int n) { if (n == 0) { return 2; } else { return 2 * mystery(n -…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 24

Multiple choice Recursion
Consider the following recursive function: public static void printDigits(int number) { if (number == 0) { return;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 25

Multiple choice Recursion
The following recursive method is intended to return the number of occurrences of a word from a phrase. 1: public static int countWord(String phrase, String…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 26

Multiple choice Recursion
Given the following code: String number = "8735"; int sum = 0; for (int i = 0;i < number.length();i++) { sum +=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 27

Multiple choice Recursion
Given the following recursive method public static int sumDigits(int number) { if (number == 0) { return 0; } int thisDigit = number % 10; return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 28

Multiple choice Recursion
Given the following recursive method public static int sumDigits(int number) { if (number == 0) { return 0; } int thisDigit = number % 10; return thisDigit +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 29

Multiple choice Recursion
The following recursive method is designed to adjust letter grades for students receiving a B, C, or D. public String adjustGrades(String grades) { if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 30

Multiple choice Recursion
What is the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 21 of 140
Page 3 of 14