| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice Test
Share
medium Solved by 8 students
String Substring Method Behavior
< Prev
Next >

All of the following statements about the String class’s substring method are true EXCEPT:

public class TestSubstring {
    public static void main(String[] args) {
        String s = "AP Computer Science";
        String sub = s.substring(3, 11);
        System.out.println(sub);
    }
}
A

Providing indices outside the valid range causes substring to throw an IndexOutOfBoundsException at runtime.

B

When a non-zero start index is provided, substring returns the entire original string.

C

If the indices provided are within range, substring returns a new String representing the specified section of the original.

D

The substring method returns a portion of the string from the start index (inclusive) to the end index (exclusive).

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki11 0m 00s 100
#2richa.tuli11 0m 21s 79
#3jeonsaw172312 1m 42s -12
#4y.seong202713 3m 26s -126
#5psak1212 3m 42s -132
#6lsj0803092212 32m 32s -1,862
APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy