-
What is the output of this program?
public class exception_Example
{
public static void main(String args[])
{
try
{
int array[] = {1, 2,3 , 4, 5};
for (int k = 0; k < 7; ++k)
System.out.print(array[k]);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.print("5");
}
}
}
-
- 123455
- 123
- 12345
- 123450
- 120345
Correct Option: A
When array index goes out of bound then ArrayIndexOutOfBoundsException exception is thrown by the system.