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.

Subtopic: Boolean Expressions Clear filter

Questions 201–210 of 357
  1. 201
  2. 202
  3. 203
  4. 204
  5. 205
  6. 206
  7. 207
  8. 208
  9. 209
  10. 210

Question 201

Multiple choice Boolean Expressions
Consider the following boolean expression, where x is an int variable. (x > 0 && x < 10)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 202

Multiple choice Boolean Expressions
Consider the following boolean expression, where a, b, and c are int variables. a > 0…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 203

Multiple choice Boolean Expressions
Consider the following method. public static String grade(int score) { String result = ""; if (score >= 90) { result = "A"; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 204

Multiple choice Boolean Expressions
Consider the following class. public class Logger { private int calls; public Logger() { calls = 0; } public boolean ping() { calls = calls + 1; return true; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 205

Multiple choice Boolean Expressions
Consider the following method. public static String tier(int score) { if (score >= 90) { return "gold"; } else if (score >=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 206

Multiple choice Boolean Expressions
Consider the boolean expression below, where a, b, and c are boolean variables.
!(a && (b || !c))
Which of the following is logically equivalent to the expression above?
Pick an answer, then check it. The solution opens in a window.

Question 207

Multiple choice Boolean Expressions
Consider the following method.
public static String rate(int n)
{
    if (n < 0 || n > 100)
    {
        return "invalid";
    }
    if (n < 25)
    {
        return "low";
    }
    if (n < 75)
    {
        return "mid";
    }
    return "high";
}
For how many integer values of n in the range \(0 \leq n \leq 100\) does rate(n) return "mid"?
Pick an answer, then check it. The solution opens in a window.

Question 208

Multiple choice Boolean Expressions
Consider the following expression, where a and b are int variables. (a > 0 && b > 0) || (a < 0…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 209

Multiple choice Boolean Expressions
Consider the following code segment, where arr is a non-null int array (possibly empty).
int i = 0;
while (i < arr.length && arr[i] != 0)
{
    i = i + 1;
}
Which of the following statements about the loop is true for every valid value of arr?
Pick an answer, then check it. The solution opens in a window.

Question 210

Multiple choice Boolean Expressions
Consider the following code segment. ArrayList<Integer> list = new ArrayList<Integer>(); list.add(3); list.add(6); list.add(3); list.add(3); list.add(9);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 201 of 357
Page 21 of 36