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 401–410 of 2,811
  1. 401
  2. 402
  3. 403
  4. 404
  5. 405
  6. 406
  7. 407
  8. 408
  9. 409
  10. 410

Question 401

Multiple choice Unit 1: Using Objects and Methods
What is printed?
int a = 6, b = 4, c = 3;
int r1 = a + b * c;
int r2 = (a + b) * c;
int r3 = r2 - r1;
int r4 = r1 * r3 / r2;
System.out.println(r4 + " " + (r1 + r2 + r3));
Pick an answer, then check it. The solution opens in a window.

Question 402

Multiple choice Unit 1: Using Objects and Methods
What is printed?
String s1 = "CAT";
String s2 = "CATALOG";
boolean a = s1.compareTo(s2) > 0;
boolean b = s2.substring(0, s1.length()).equals(s1);
boolean c = s1.length() < s2.length();
System.out.println(a + " " + b + " " + c);
Pick an answer, then check it. The solution opens in a window.

Question 403

Multiple choice Unit 1: Using Objects and Methods
What is printed?
int x = 9, y = 4;
double a = x / y;
double b = 1.0 * x / y;
System.out.println(a + " " + b + " " + (a == b));
Pick an answer, then check it. The solution opens in a window.

Question 404

Multiple choice Unit 1: Using Objects and Methods
What is printed?
String word = "ABCABC";
String first = word.substring(0, 3);
String last = word.substring(word.length() - 3);
System.out.println(first.equals(last) + " " + first.compareTo(last));
Pick an answer, then check it. The solution opens in a window.

Question 405

Multiple choice Unit 1: Using Objects and Methods
What is printed?
int n = 8521;
int d1 = n / 1000;
int d2 = n / 100 % 10;
int d3 = n / 10 % 10;
int d4 = n % 10;
System.out.println(d4 * 1000 + d3 * 100 + d2 * 10 + d1);
Pick an answer, then check it. The solution opens in a window.

Question 406

Multiple choice Unit 1: Using Objects and Methods
What is printed?
String s = "ENGINEERING";
int i = s.indexOf("NEE");
String t = s.substring(0, i) + s.substring(i + 3);
System.out.println(t + " " + t.length());
Pick an answer, then check it. The solution opens in a window.

Question 407

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment.
int x = 25;
int y = 7;
double z = (x + y) / 2 - x % y * 2.0;
What value is stored in z after the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 408

Multiple choice Unit 1: Using Objects and Methods
Consider the following declarations.
String a = "hello";
String b = new String("hello");
String c = a;
Which of the following statements is true about the three references?
Pick an answer, then check it. The solution opens in a window.

Question 409

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment.
int x = -17;
int y = 5;
System.out.println(x / y + " " + x % y);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 410

Multiple choice Unit 1: Using Objects and Methods
Consider the following code segment.
String s = "2026Exam";
String r = s.substring(4) + s.substring(0, 4);
int p = r.indexOf("a");
What value is stored in p after the code segment executes?
Pick an answer, then check it. The solution opens in a window.
Question 401 of 2,811
Page 41 of 282