Java performs ________, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.
a. active array sequencing
b. buffer overrun protection
c. array bounds checking
d. scope resolution binding

Respuesta :

Limosa

Answer:

The correct option to the following question is an option (c) array bounds checking

Explanation:

Array bound checking is the checking is the checking of the elements of an array, when the number of the array goes beyond the number of array that is given at the time of declaration of the array.

This time if the programmer executes the program than an error arises that is 'IndexOutOfBoundsException'.

For Example:

//import packages

public class A {   //define class

//define main function

  public static void main(String args[]) {    

     int[] ar = {8, 6, 7, 0, 2, 23, 7};    //set integer array type variable

     System.out.println("Array are:: ");  //print message

     System.out.println(Arrays.toString(ar));    //convert array into string

     Scanner s = new Scanner(System.in);   //creating object of Scanner

     System.out.println("Elements enter ::");   //print message

     int e = s.nextInt();

     System.out.println("Elements are :: "+ar[e]);  //print array

  }

}

Output:

Array are::

[8, 6, 7, 0, 2, 23, 7]

Elements enters ::

7

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 7

at A.main(A.java:12)