AP® Computer Science A Practice Questions
Work through AP Computer Science A practice questions unit by unit, 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.
Multiple choice
Unit 1: Using Objects and Methods
Question 562
Multiple choice
Unit 1: Using Objects and Methods
Question 563
Multiple choice
Unit 1: Using Objects and Methods
Consider the following code segment.
String s = "method";
String t = s.substring(2);
int value = t.length() + s.indexOf(t.substring(1, 3));
What value is stored in value?
Pick an answer, then check it. The solution opens in a window.
ACorrect answer
Main Solution
Answer
Answer: A. t is "thod", so t.length() is 4. The expression t.substring(1, 3) is "ho", which begins at index 3 in "method". The total is 7.
Answer: Correct: A
A
7
B
6
C
5
D
3
Answer images
Question 564
Multiple choice
Unit 1: Using Objects and Methods
Question 565
Multiple choice
Unit 1: Using Objects and Methods
Question 566
Free response
Unit 1: Using Objects and Methods
Question 567
Free response
Unit 1: Using Objects and Methods
Question 568
Free response
Unit 1: Using Objects and Methods
Question 569
Free response
Unit 1: Using Objects and Methods
Question 570
Free response
Unit 1: Using Objects and Methods
Question 561 of 3,140
Page 57 of 314
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.

