Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
hard

Exception Handling With String Substring

Mark
< Prev
Next >

What is printed as a result of executing the following code segment?

public class Main {
    public static void main(String[] args) {
        String s = "immutable";
        try {
            System.out.println(s.substring(-1, 3));
        } catch (Exception e) {
            System.out.println(e.getClass().getSimpleName());
        }
    }
}
A

IndexOutOfBoundsException

B

StringIndexOutOfBoundsException

C

NullPointerException

D

RuntimeException

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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