Verityprep
Question Bank · Unit 1

AP® Computer Science A Using Objects and Methods Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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.

Subtopic: Using Objects Clear filter

Questions 291–300 of 454
  1. 291
  2. 292
  3. 293
  4. 294
  5. 295
  6. 296
  7. 297
  8. 298
  9. 299
  10. 300

Question 291

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 292

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 293

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 294

Multiple choice Using Objects
Consider the following code segment. String s = "abracadabra"; int p = s.indexOf("ab", 1); int c = s.indexOf("c");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 295

Multiple choice Using Objects
Consider the following code segment. String a = "hello"; String b = "he" + "llo"; String c = "he"; String d = c +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 296

Multiple choice Using Objects
Consider the following code segment. String s = "Computer Science A"; int p = s.indexOf(" "); int q = s.indexOf(" ", p + 1); String first = s.substring(0, p);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 297

Multiple choice Using Objects
Consider the following declarations.
String s1 = "AP";
String s2 = s1 + "CSA";
String s3 = "APCSA";
Which of the following statements must be true?
Pick an answer, then check it. The solution opens in a window.

Question 298

Multiple choice Using Objects
Consider the following code segment. String code = "practice"; String part =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 299

Multiple choice Using Objects
Consider the following code segment. String a = "cat"; String b = "car"; boolean x = a.compareTo(b) > 0;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 300

Multiple choice Using Objects
What is printed by the following code segment? String s…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 291 of 454
Page 30 of 46