Home » JAVA Programming » Arrays » Question
  1. What is the output of below snippet?

    Obj[] names = new String[10];
    name[0] = new Integer(0);
    1. ArrayIndexOutOfBoundsException
    2. Compilation Error
    3. Code runs successfully
    4. ArrayStoreException
    5. None of these
Correct Option: D

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 type of array.



Your comments will be displayed only after manual approval.