-
What is the output of this program?
public class ExceptionHandling_Example
{
public static void main(String args[])
{
try
{
int array[] = {5,6,7,8};
for (int K = 0; K < 7; ++K)
System.out.print(array[K]);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.print("9");
}
}
}
-
- Compilation Error
- 56789
- Runtime Error
- 12345
- 56780
Correct Option: B
When array index goes out of bound then ArrayIndexOutOfBoundsException exception is thrown by the system.