Courseiva
Java Basics and SyntaxhardMultiple ChoiceObjective-mapped

1Z0-811 Java Basics and Syntax Practice Question

A developer uses the following array initialization: int[] nums = new int[]{1, 2, 3}; Which of the following is true?

⚠ Common exam trap

The 1Z0-811 exam often tests the distinction between array declaration with an initializer list (which must be in a single statement) and the anonymous array syntax shown here, leading candidates to mistakenly think the syntax is invalid or that the array has default values.

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

The array has length 3.

The array initialization `int[] nums = new int[]{1, 2, 3};` explicitly creates an array of length 3, containing the elements 1, 2, and 3. The syntax is valid and the array is not initialized with default values; it is initialized with the specified literal values.

Answer analysis

Option-by-option breakdown

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

  • This is invalid syntax.

    Why it's wrong here

    Syntax is valid for anonymous array creation.

  • The array is initialized with default values.

    Why it's wrong here

    Explicit values are provided.

  • The array has length 3.

    Why this is correct

    Three elements were provided.

  • The array can only store numbers up to 3.

    Why it's wrong here

    No such restriction.

About these practice questions

One of 481 original 1Z0-811 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.