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 251–260 of 454
  1. 251
  2. 252
  3. 253
  4. 254
  5. 255
  6. 256
  7. 257
  8. 258
  9. 259
  10. 260

Question 251

Multiple choice Using Objects
Consider the following method: public static String encode(String s) { String result = ""; for (int i =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 252

Multiple choice Using Objects
Consider the following code segment. String s = "PRACTICE"; String t = s.substring(2, 6); int result =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 253

Multiple choice Using Objects
What is printed by the following? String p = "apple"; String q = "apricot"; String r = "app";…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 254

Multiple choice Using Objects
What is printed by the following? String msg = "artificial intelligence"; int space = msg.indexOf(" "); String first =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 255

Multiple choice Using Objects
What is printed? String a = "Java"; String b = "java"; String c = "Java";…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 256

Multiple choice Using Objects
What is printed by the following? String s = "ABCDEFGHIJ"; String t =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 257

Multiple choice Using Objects
What is printed? String a = "code"; String b = "program"; int diff =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 258

Multiple choice Using Objects

What is printed?

String s = "abcabc";
int first = s.indexOf("bc");
String t = s.substring(first + 2);
int second = t.indexOf("bc");
System.out.println(first + " " + second + " " + (first + second + 2));
Pick an answer, then check it. The solution opens in a window.

Question 259

Multiple choice Using Objects

Consider the following code segment.

String s = "EXAMINATION";
int k = s.indexOf("NATION");
String t = s.substring(0, k) + s.substring(k + 3);
System.out.println(t + " " + t.length());

What is printed as a result of executing the code segment?

Pick an answer, then check it. The solution opens in a window.

Question 260

Multiple choice Using Objects

What is printed?

String s = "ABCDEFGHIJ";
int m = s.length() / 2;
String left = s.substring(0, m);
String right = s.substring(m);
String result = right + left;
System.out.println(result.substring(3, 7));
Pick an answer, then check it. The solution opens in a window.
Question 251 of 454
Page 26 of 46