Verityprep
Question Bank

AP® Computer Science A Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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 411–420 of 2,811
  1. 411
  2. 412
  3. 413
  4. 414
  5. 415
  6. 416
  7. 417
  8. 418
  9. 419
  10. 420

Question 411

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment.
double a = Math.pow(4, 3);
double b = Math.sqrt(81);
double c = Math.abs(-7.5);
double r = a - b * c;
What value is stored in r?
Pick an answer, then check it. The solution opens in a window.

Question 412

Multiple choice Unit 1: Using Objects and Methods
Consider the following method and code segment.
public static void change(int x, int[] a)
{
    x = x + 10;
    a[0] = a[0] + 10;
}

int n = 5;
int[] arr = { 5 };
change(n, arr);
System.out.println(n + " " + arr[0]);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 413

Multiple choice Unit 1: Using Objects and Methods
Consider the following statement.
System.out.println(1 + 2 + "+" + 3 + 4 + "=" + (3 + 4));
What is printed when the statement executes?
Pick an answer, then check it. The solution opens in a window.

Question 414

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment, which is intended to swap the values of a and b without using a temporary variable.
int a = 12;
int b = 5;
a = a - b;
b = a + b;
a = b - a;
System.out.println(a + " " + b);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 415

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment.
String s = "Advanced Placement";
int n = s.length() - s.indexOf("P");
String t = s.substring(s.length() - n);
What value is stored in t after the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 416

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment.
String s = null;
String t = "value: " + s;
System.out.println(t + "!");
What is the result of executing the code segment?
Pick an answer, then check it. The solution opens in a window.

Question 417

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment.
double d = 3.9;
int n = 7;
int r = n / 2 + 1;
double s = d * r - n % 4;
What value is stored in s after the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 418

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment. int a = 9; int b = 4; double x = a / b…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 419

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment. double y = Math.sqrt(Math.pow(3, 2) +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 420

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment.
int x = 23;
int y = -4;
System.out.println(x % y);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.
Question 411 of 2,811
Page 42 of 282