Verityprep
Question Bank · Unit 1

AP® Computer Science A Using Objects and Methods Practice Questions

Work through AP Computer Science A practice questions on Using Objects and Methods, 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 521–530 of 776
  1. 521
  2. 522
  3. 523
  4. 524
  5. 525
  6. 526
  7. 527
  8. 528
  9. 529
  10. 530

Question 521

Multiple choice Primitive Types
Consider the following code segment.
double r = 7.5 % 2.0;
int q = 17 % 5;
System.out.println(r + " " + q);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 522

Multiple choice Primitive Types
Consider the following code segment.
int x = 6;
x += 2;
x *= x - 3;
x -= 10;
System.out.println(x);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 523

Multiple choice Using Objects
Consider the following code segment. String word = "programming"; String a = word.substring(3); String b…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 524

Multiple choice Using Objects
Consider the following code segment. String s = "mississippi"; int p = s.indexOf("ss"); int q =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 525

Multiple choice Using Objects
Consider the following code segment.
String a = "java";
String b = "java";
String c = new String("java");
System.out.println((a == b) + " " + (a == c) + " " + a.equals(c));
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 526

Multiple choice Using Objects
Consider the following code segment. int x = 2; int y = 5; if (x < y && y % x == 1) { x = x + y; } if (x >…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 527

Multiple choice Using Objects
Consider the following code segment.
String s = "alphabet";
int x = s.length() - s.indexOf("bet");
System.out.println(x);
What is printed when the code segment executes?
Pick an answer, then check it. The solution opens in a window.

Question 528

Multiple choice Using Objects
Consider the following code segment. int x = 18; int count = 0; while (x > 2) { x = x / 2;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 529

Multiple choice Using Objects
Consider the following method. public static String classify(int n) { if (n < 0) { return "neg"; } else if (n == 0) { return "zero"; } else if (n < 10) { return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 530

Multiple choice Primitive Types
Consider the following code segment. int a = 17; int b = 5; double r = a / b + 1.0 *…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 521 of 776
Page 53 of 78