| 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
< Prev
Next >

What does the program print when executed?

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

RuntimeException

B

IndexOutOfBoundsException

C

StringIndexOutOfBoundsException

D

NullPointerException

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy