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.

Subtopic: Using Objects Clear filter

Questions 341–350 of 546
  1. 341
  2. 342
  3. 343
  4. 344
  5. 345
  6. 346
  7. 347
  8. 348
  9. 349
  10. 350

Question 341

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 342

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 343

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 344

Free response Using Objects
The Greenfield Public Library is undergoing a digital transformation. Every book in the library has a checkout record that includes the number of days it has…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 345

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 346

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 347

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 348

Multiple choice Using Objects

What is printed?

String w1 = "banana";
String w2 = "band";
String w3 = "ban";
int r1 = w1.compareTo(w2);
int r2 = w2.compareTo(w3);
System.out.println((r1 > 0) + " " + (r2 < 0) + " " + (r1 + r2 > 0));
Pick an answer, then check it. The solution opens in a window.

Question 349

Multiple choice Using Objects

What is printed?

String p = "Java";
String q = p.substring(1) + p.length() + p.substring(0, 1);
System.out.println(q + " " + q.indexOf("4"));
Pick an answer, then check it. The solution opens in a window.

Question 350

Multiple choice Using Objects

What is printed by the following code segment?

String s = "programming";
String a = s.substring(0, s.indexOf("gram"));
String b = s.substring(s.indexOf("m") + 1, s.indexOf("ing"));
System.out.println(a.length() + b.length() + " " + a + b);
Pick an answer, then check it. The solution opens in a window.
Question 341 of 546
Page 35 of 55