Which of the following exceptions is thrown when accessing a character beyond the length of a string?

  1. IndexOutOfBoundsException
  2. NullPointerException
  3. StringIndexOutOfBoundsException
  4. CharSequenceException
Correct answer StringIndexOutOfBoundsException

Explanation

Accessing an invalid index in a string causes StringIndexOutOfBoundsException.

Update: Admin added a tag on this question

Topics

By Admin · · 28 views