| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
medium Solved by 12 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

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

B

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

C

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

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
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki11 0m 00s 100
#2richa.tuli11 0m 21s 79
#3liuwilliam07241012 1m 39s -9
#4jeonsaw172312 1m 42s -12
#5y.seong202713 3m 26s -126
#6psak1212 3m 42s -132
#7chunxiangxu.cxu03 5m 10s -340
#8lsj0803092212 32m 32s -1,862
Items per page:
10
1 – 8 of 8
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy