6. What is the output of the following Java code?
public class array
public static void main(String args[])
int []arr = {1,2,3,4,5};

a) 4
b) 5
c) ArrayIndexOutOfBoundsException
d) InavlidInputException

Answer: c
Explanation: Trying to access an element beyond the limits of an array gives ArrayIndexOutOfBoundsException.

Leave a Reply

Your email address will not be published.