Courseiva
Arrays and MethodseasyMultiple ChoiceObjective-mapped

1Z0-811 Arrays and Methods Practice Question

A banking application stores daily transaction amounts in an array. Which declaration correctly creates an array of 31 double values?

⚠ Common exam trap

Oracle often tests the distinction between array size and index range, tricking candidates into choosing an array of size 30 (index 0-29) when 31 elements are needed, or confusing the data type (int vs double) for monetary 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

double[] transactions = new double[31];

It uses the proper syntax to declare an array of double values and initializes it with a size of 31, which allocates memory for 31 double elements, each defaulting to 0.0. In Java, the array size must be specified when using the 'new' keyword, and the index range is 0 to 30, accommodating exactly 31 daily transaction amounts.

Answer analysis

Option-by-option breakdown

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

  • double[] transactions = new double[31];

    Why this is correct

    Correct syntax: declares array and allocates 31 elements.

  • double transactions[] = new double[30];

    Why it's wrong here

    Only allocates 30 elements, not 31.

  • int[] transactions = new int[31];

    Why it's wrong here

    Data type should be double, not int.

  • double[] transactions = new double[];

    Why it's wrong here

    Missing size; compilation error.

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.