A

Admin • 828.70K Points
Coach

Q. What does this code display?

Code:
Object[] cars = new String[3];
cars[0] = new Integer(0);
  • (A) The code runs successfully
  • (B) Compilation error
  • (C) ArrayStoreException
  • (D) ArrayIndexOutOfBoundsException
  • Correct Answer - Option(C)
  • Views: 11
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
“ArrayIndexOutOfBoundsException” comes when code tries to access an invalid index for a given array. “ArrayStoreException” comes when you have stored an element of type other than the array type.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.