Verityprep
Question Bank

AP® Computer Science A Practice Questions

Work through AP Computer Science A practice questions unit by unit, 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 31–40 of 3,140
  1. 31
  2. 32
  3. 33
  4. 34
  5. 35
  6. 36
  7. 37
  8. 38
  9. 39
  10. 40

Question 31

Multiple choice Unit 1: Using Objects and Methods
Consider the following method. public void sample(int num1, int num2) { int result = 99; if (num1 == num2) {result = 0;} else if (num1>num2){result = 1;} else…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 32

Multiple choice Unit 1: Using Objects and Methods
Consider the following method. public static void conditionTest(int num1, int num2) { if ((num1>0) && (num2>0)) { if (num1>num2) System.out.println("A"); else…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 33

Multiple choice Unit 1: Using Objects and Methods
What is the output from the following code? String s = "Computer Science is fun!"; String s1 =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 34

Multiple choice Unit 1: Using Objects and Methods
Consider the following method that is intended to determine if the double values d1 and d2 are close enough to be considered equal. For example, given a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 35

Multiple choice Unit 1: Using Objects and Methods
Consider the following instance variable and methods. You may assume that data has been initialized with length > 0. The methods are intended to return the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 36

Multiple choice Unit 1: Using Objects and Methods
Consider the following method. public String mystery(String input) { String output = ""; for (int k = 1;k < input.length();k =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 37

Multiple choice Unit 1: Using Objects and Methods
Assume that myList is an ArrayList that has been correctly constructed and populated…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 38

Multiple choice Unit 1: Using Objects and Methods
Consider the following method. public static String scramble(String word, int howFar) { return word.substring(howFar +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 39

Multiple choice Unit 1: Using Objects and Methods
Consider the following method. public int compute(int n, int k) { int answer = 1; for (int i = 1;i <= k;i++) answer…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 40

Multiple choice Unit 1: Using Objects and Methods
Consider the following method. public void test(int x) { int y; if (x % 2 == 0) y = 3; else if (x > 9) y = 5; else y =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 31 of 3,140
Page 4 of 314