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 491–500 of 3,140
  1. 491
  2. 492
  3. 493
  4. 494
  5. 495
  6. 496
  7. 497
  8. 498
  9. 499
  10. 500

Question 491

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 492

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 493

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 494

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 495

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 496

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 497

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 498

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 499

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 500

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 491 of 3,140
Page 50 of 314