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.
Question 392
Question 393
Question 394
Question 395
Question 396
int a = 88;
a = a / 6;
a = a / 4;
a = a * 4 * 6;
System.out.println(a);Main Solution
Solution:
Correct: A. 88/6 = 14 (int division). 14/4 = 3. 346 = 72. Truncation from the two divisions loses 16.
Answer: Correct: A
Answer images
Question 397
String s = "TRIGONOMETRY";
int k = s.indexOf("NOM");
String t = s.substring(k, k + 4);
System.out.println(t + " " + t.indexOf("O"));Main Solution
Solution:
Correct: B. In "TRIGONOMETRY", indexOf("NOM") scans N(5)O(6)M(7) → k = 5. substring(5, 9) = "NOME". In "NOME", indexOf("O") = 1. Output: NOME 1.
Answer: Correct: B
Answer images
Question 398
int x = 73;
int a = x / 10;
int b = x % 10;
int y = b * 10 + a;
int z = y / 10 + y % 10;
System.out.println(z);Main Solution
Solution:
Correct: C. a = 73/10 = 7. b = 73%10 = 3. y = 3*10+7 = 37. z = 37/10 + 37%10 = 3 + 7 = 10.
Answer: Correct: C
Answer images
Question 399
int p = 40, q = 9;
int d = p / q;
int r = p % q;
double val = Math.pow(d, r - 1) + Math.pow(r, d - 2);
System.out.println(val);Main Solution
Solution:
Correct: D. d = 40/9 = 4. r = 40%9 = 4. pow(4, 3) = 64.0. pow(4, 2) = 16.0. 64.0 + 16.0 = 80.0.
Answer: Correct: D
Answer images
Question 400
String s = "PARAMETRIC";
int n = s.indexOf("MET");
String out = s.substring(n - 2, n + 5);
System.out.println(out);Main Solution
Solution:
Correct: A. "PARAMETRIC": indexOf("MET") finds M(4)E(5)T(6) → n = 4. substring(2, 9) = "RAMETRI".
Answer: Correct: A
Answer images
AP® and Advanced Placement® are registered trademarks of the College Board, which is not affiliated with, and does not endorse, Verityprep. Names are used for identification purposes only.

