| preferred AP College board partner for AP classes
AP Computer Science A/Unit 6: Array
Start Practice Test
Share
easy Solved by 10 students
Array Index Out Of Bounds Error
< Prev
Next >

What error does the above code produce when executed?

public class ArrayMistake {
  public static void main(String[] args) {
      int[] numbers = {1, 2, 3, 4, 5};
      for (int i = 0; i <= numbers.length; i++) {
          System.out.print(numbers[i] + " ");
      }
  }
}
A

ArrayIndexOutOfBoundsException

B

Compilation Error

C

NullPointerException

D

No error, prints all elements

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1upadhgau00011 0m 00s 100
#2sathilak00011 0m 05s 95
#3singhris00011 0m 12s 88
#4bommasam00022 1m 54s 86
#5y.seong202711 1m 25s 15
#6suhanakochhar00602 1m 18s -98
#7geethasailaja27 11m 16s -526
APFIVE © 2020.
Email: [email protected]|Privacy Policy