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 261–270 of 454
  1. 261
  2. 262
  3. 263
  4. 264
  5. 265
  6. 266
  7. 267
  8. 268
  9. 269
  10. 270

Question 261

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 262

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 263

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 264

Multiple choice Using Objects

What is printed?

String s = "PROGRAMMING";
int k = s.indexOf("RAM");
String t = s.substring(k, k + 5);
System.out.println(t + " " + t.indexOf("M"));
Pick an answer, then check it. The solution opens in a window.

Question 265

Multiple choice Using Objects

What is printed?

String s = "JAVA";
String t = "";
t = t + s.substring(3);
t = t + s.substring(1, 3);
t = t + s.substring(0, 1);
System.out.println(t + " " + t.indexOf("A"));
Pick an answer, then check it. The solution opens in a window.

Question 266

Multiple choice Using Objects

What is printed?

String s = "COMPUTATION";
String a = s.substring(0, 3);
String b = s.substring(s.length() - 3);
String c = a + b;
System.out.println(c.indexOf("IO") + c.length());
Pick an answer, then check it. The solution opens in a window.

Question 267

Multiple choice Using Objects

What is printed?

String s1 = "APPLE";
String s2 = "APPLICATION";
boolean a = s1.compareTo(s2) < 0;
boolean b = s1.equals(s2.substring(0, s1.length()));
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 268

Multiple choice Using Objects

What is printed?

String word = "ABRACADABRA";
String first = word.substring(0, 4);
String last = word.substring(word.length() - 4);
System.out.println(first.equals(last) + " " + first.compareTo(last));
Pick an answer, then check it. The solution opens in a window.

Question 269

Multiple choice Using Objects
public static String getResult() { String text = "banana"; int len = text.length(); String part =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 270

Multiple choice Using Objects
The Book class is defined as follows: public class Book { private String title; private int pages; public Book(String t, int p) { title = t; pages = p; } public…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 261 of 454
Page 27 of 46