in java Write a program that contains a bounds error. Run theprogram. What happens on your computer?
Answer
Error output will be:
Code is shown below:
public class Main
{
public static void main(String[] args)
{
int array[] = {1, 2, 3};
for (int i=0; i<=array.length; i++)
System.out.println(array[i]);
}
}
Note:
This error cannot be find at the compilation time.
It can be hit only after the execution.
An exception will be thrown to the computer screen intimatingthe user about the out of bounds of an array occurred.
Here 0,1,2 position
OR
OR