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 371–380 of 1,222
  1. 371
  2. 372
  3. 373
  4. 374
  5. 375
  6. 376
  7. 377
  8. 378
  9. 379
  10. 380

Question 371

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 372

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 373

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 374

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 375

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 376

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 377

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 378

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 379

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 380

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 371 of 1,222
Page 38 of 123