Courseiva
Arrays and MethodseasyMultiple ChoiceObjective-mapped

1Z0-811 Array Initializer Syntax Practice Question

Which of the following correctly uses the shorthand array initializer to declare and initialize an array of strings with the elements "A", "B", and "C"?

⚠ Common exam trap

The trap is that some candidates might think that the 'new' keyword is required, but Java allows the shorthand array initializer directly in a declaration, as shown in Option D.

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

String[] arr = {"A", "B", "C"};

Option D correctly uses the shorthand array initializer with curly braces directly in the declaration. Option A uses the full syntax with the 'new' keyword, which is also valid but not the shorthand. Option B is wrong because it uses parentheses. Option C is wrong because it uses square brackets.

Answer analysis

Option-by-option breakdown

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

  • String[] arr = new String[] {"A", "B", "C"};

    Why it's wrong here

    Correct. This uses anonymous array creation with 'new' to declare and initialize the array in one statement.

  • String[] arr = ("A", "B", "C");

    Why it's wrong here

    Incorrect. Array initializers use curly braces, not parentheses.

  • String[] arr = ["A", "B", "C"];

    Why it's wrong here

    Incorrect. Array initializers use curly braces, not square brackets.

  • String[] arr = {"A", "B", "C"};

    Why this is correct

    Correct. This uses the shorthand array initializer syntax with curly braces.

Visual reference

Client Server SYN (seq=100) SYN-ACK (seq=200, ack=101) ACK (ack=201) Connection established — data transfer begins

About these practice questions

Courseiva writes every 1Z0-811 question from scratch — 481 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.