Question 401
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?
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

