Verityprep
Question Bank · Unit 2

AP® Computer Science A Selection and Iteration Practice Questions

Work through AP Computer Science A practice questions on Selection and Iteration, 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 740
  1. 31
  2. 32
  3. 33
  4. 34
  5. 35
  6. 36
  7. 37
  8. 38
  9. 39
  10. 40

Question 31

Multiple choice Boolean Expressions
The Boolean expression (x==y && !(x==y)) || ( x!=y &&…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 32

Multiple choice Iteration
What are the values of a and b after the for loop finishes? int a = 5, b…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 33

Multiple choice Boolean Expressions
Consider the following code segment. int x = 7; int y = 3; if ((x < 10) && (y < 0)) System.out.println("Value is: "…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 34

Multiple choice Boolean Expressions
Assume that a and b have been defined and initialized as int values. The expression !(!(a !=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 35

Multiple choice Iteration
Questions refer to the following method. public static int mystery(int n) { int x = 1; int y = 1; // Point A while (n > 2)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 36

Multiple choice Iteration
Consider the following code segment. for (int k = 1; k <= 100; k++) if ((k % 4) == 0)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 37

Multiple choice Iteration
Consider the following code segment. int sum = 0; int k = 1; while (sum < 12 || k < 4) sum…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 38

Multiple choice Iteration
Consider the following code segment. int num = 2574; int result = 0; while (num > 0) { result = result * 10 +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 39

Multiple choice Iteration
Consider the following code segment. int x = 1; while ( /* missing code */ ) { System.out.print(x + " "); x = x + 2; } Consider the following possible…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 40

Multiple choice Boolean Expressions
Assume that x and y have been declared and initialized with int values. Consider the following Java…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 31 of 740
Page 4 of 74