Courseiva
Java Basics and SyntaxhardMultiple ChoiceObjective-mapped

1Z0-811 Java Basics and Syntax Practice Question

Given: int[] arr = {10,20,30}; System.out.println(arr[3]); What is the result?

⚠ Common exam trap

The trap here is that candidates may forget arrays are zero-indexed and mistakenly think the last element is at index 3, or assume Java returns a default value like 0 for invalid indices.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

ArrayIndexOutOfBoundsException

Arrays in Java are zero-indexed, so a valid index for an array of length 3 is 0, 1, or 2. Accessing index 3 is out of bounds, causing an ArrayIndexOutOfBoundsException at runtime.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ArrayIndexOutOfBoundsException

    Why this is correct

    Correct: runtime exception due to invalid index.

  • 30

    Why it's wrong here

    Index 3 is out of bounds.

  • 0

    Why it's wrong here

    No default value; exception thrown.

  • NullPointerException

    Why it's wrong here

    Array is not null.

About these practice questions

This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.