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 91–100 of 140
  1. 91
  2. 92
  3. 93
  4. 94
  5. 95
  6. 96
  7. 97
  8. 98
  9. 99
  10. 100

Question 91

Multiple choice Recursion
Consider the following method: public String filter(String str, String pattern) { int pos = str.indexOf(pattern); if (pos == -1) return str; else return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 92

Multiple choice Recursion
Consider the following method: private int product(int n) { if (n <= 1)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 93

Multiple choice Recursion
Consider the following method: private int product(int n) { if (n <= 1) return 1; else return n * product(n - 2); }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 94

Multiple choice Recursion
Consider the following recursive method: public static void smile(int n) { if (n == 0) { return; } for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 95

Multiple choice Recursion
Consider the following recursive method: public static void smile(int n) { if (n == 0) { return; } for (int k = 1; k <= n; k++) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 96

Multiple choice Recursion
Consider the following method: public String encrypt(String word) { int pos = word.length() / 2; if (pos >= 1) { word =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 97

Multiple choice Recursion
What is the output from mystery(4321) when mystery is defined as follows? // preconditions: x >= 0…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 98

Multiple choice Recursion
Consider the following code segment: public static boolean check(String s) { return s.length() >= 2 && (s.substring(0,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 99

Multiple choice Recursion
What is printed when the following main method is executed? public class Searcher { private int[] arr = {1, 3, 5, 8, 9}; public int mystery(int low, int high,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 100

Multiple choice Recursion
Consider the following method. What value is returned from a call of mystery(5)?…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 91 of 140
Page 10 of 14