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 451–460 of 776
  1. 451
  2. 452
  3. 453
  4. 454
  5. 455
  6. 456
  7. 457
  8. 458
  9. 459
  10. 460

Question 451

Multiple choice Primitive Types
What is printed? Integer a = 7; Integer b = 3; String…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 452

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 453

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 454

Multiple choice Primitive Types

What is printed?

int x = - 15, y = 4;
int z = Math.abs(x) / y;
int w = Math.abs(x) % y;
System.out.println(Math.abs(z - w) + Math.pow(w, z));
Pick an answer, then check it. The solution opens in a window.

Question 455

Multiple choice Primitive Types

What is printed by the following code segment?

int a = 58;
int b = a / 10 + a % 10;
int c = b * b;
double d = Math.sqrt(c - 25);
System.out.println(b + " " + d);
Pick an answer, then check it. The solution opens in a window.

Question 456

Multiple choice Primitive Types

What is printed?

Integer x = 17;
Integer y = 5;
double result = Math.pow(x % y, x / y) + 0.5;
System.out.println(result);
Pick an answer, then check it. The solution opens in a window.

Question 457

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 458

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 459

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 460

Multiple choice Primitive Types

What is printed?

double a = Math.pow(2, 10);
double b = Math.pow(2, 7);
System.out.println((a - b) + " " + (a / b));
Pick an answer, then check it. The solution opens in a window.
Question 451 of 776
Page 46 of 78