Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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 1–10 of 140
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10

Question 1

Multiple choice Recursion
Consider the following recursive method. public static void stars(int num) { if (num == 1) { return; } stars(num - 1); for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2

Multiple choice Recursion
Consider the following method. public static int calcMethod(int num) { if (num == 0) { return 10;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3

Multiple choice Recursion
Consider the following recursive method. public static boolean recurMethod(String str) { if (str.length() <= 1) { return true; } else if (str.substring(0,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 4

Multiple choice Recursion
Consider the following method. public static void showMe(int arg) { if (arg < 10) { showMe(arg +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 5

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 6

Multiple choice Recursion
Consider the following recursive method. /** Precondition: num >= 0 */ public static int what(int num) { if (num < 10) { return 1; } else { return 1 + what(num…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 7

Multiple choice Recursion
Consider the following method. /** Precondition: 0 < numVals <= nums.length */ public static int mystery(int[] nums, int v, int numVals) { int k = 0; if (v ==…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 8

Multiple choice Recursion
Consider the following method. // precondition: x >= 0 public void mystery(int x) { if ((x / 10) != 0) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 9

Multiple choice Recursion
Consider the following recursive method. public static String recur(int val) { String dig = "" + (val % 3); if (val / 3 > 0) return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 10

Multiple choice Recursion
Consider the following method. public String goAgain(String str, int index) { if (index >= str.length()) return str; return str +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1 of 140
Page 1 of 14