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 501–510 of 3,140
  1. 501
  2. 502
  3. 503
  4. 504
  5. 505
  6. 506
  7. 507
  8. 508
  9. 509
  10. 510

Question 501

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 502

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 503

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 504

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 505

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 506

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 507

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 508

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 509

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 510

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment.
int n = 6;
n += n * 2;
n -= n / 4;
System.out.println(n);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.
Question 501 of 3,140
Page 51 of 314