Computer Applications

The java statement System.out.println(x[x.length]) results in:

  1. logical error
  2. syntax error
  3. run time error
  4. no error

Java Arrays

6 Likes

Answer

run time error

Reason — In Java, arrays are zero-indexed, meaning the valid indices range from 0 to x.length - 1. x.length gives the total number of elements in the array, but accessing x[x.length] tries to access an index outside the valid range, resulting in a ArrayIndexOutOfBoundsException at runtime.

Answered By

3 Likes


Related Questions