What is the result?

Given: What is the result?

Given: What is the result?

A.
An ArrayIndexOutOfBoundsException is thrown at runtime

B.
A NullPointException is thrown at runtime

C.
d is output

D.
There is no output

E.
A StringIndexOutOfBoundsException is thrown at runtime

F.
A StringArrayIndexOutOfBoundsException is thrown at runtime



Leave a Reply 3

Your email address will not be published. Required fields are marked *


Kevin

Kevin

Answer given is correct, tried it in eclipse

imyrta

imyrta

Answer: E

Explanation:

The method charAt(int index) throws an IndexOutOfBoundsException if the index argument is negative or not less than the length of this string.

In this case since the object is a string and 11 is not less than the length of this string the StringIndexOutOfBoundsException(a subclass of IndexOutOfBoundsException) will be thrown.