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 51–60 of 140
  1. 51
  2. 52
  3. 53
  4. 54
  5. 55
  6. 56
  7. 57
  8. 58
  9. 59
  10. 60

Question 51

Multiple choice Recursion
public int result(int n) { if (n == 1) return 2; else return 2 * result(n - 1); } If…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 52

Multiple choice Recursion
Refer to method mystery. public int mystery(int n, int a, int d) { if (n == 1) return a;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 53

Multiple choice Recursion
Refer to method f. public int f(int k, int n) { if (n == k) return k; else if (n > k)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 54

Multiple choice Recursion
What does method recur do? / * x is an array of n integers. * n is a positive integer. * / public int recur(int[] x,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 55

Multiple choice Recursion
Which best describes what the printString method below does? public void printString(String s)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 56

Multiple choice Recursion
Refer to the method power. / * * Returns base raised to the expo power. * Precondition: * - base is a nonzero real number. * - expo is an integer. * / public…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 57

Multiple choice Recursion
Consider the following method. public void doSomething(int n) { if (n > 0) { doSomething(n - 1);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 58

Multiple choice Recursion
A user enters several positive integers at the keyboard and terminates the list with a sentinel (-999). A writeEven method reads those integers and outputs the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 59

Multiple choice Recursion
What is returned by mystery(3)?…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 60

Multiple choice Recursion
What does t(5) return? // Precondition: n is positive. public int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 51 of 140
Page 6 of 14