What happens if you try to access an index out of bounds in a string?

  1. Returns null
  2. Returns 0
  3. Throws StringIndexOutOfBoundsException
  4. Compiles but skips
Correct answer Throws StringIndexOutOfBoundsException

Explanation

Accessing an invalid index in a string throws StringIndexOutOfBoundsException.

Update: Admin added a tag on this question

Topics

By Admin · · 29 views