Prepare for the Java FPT Software Academy Test. Study with concise flashcards and multiple choice questions, each with detailed explanations. Get ready to excel in your exam!

Multiple Choice

Which declaration initializes an array in a single statement with five elements?

Initializing an array in one statement means creating the array and supplying its elements at the same time using an initializer list. The number of values you put inside the braces determines the array’s length. This option does exactly that: int arr[] = {1,2,3,4,5}; It creates the array and initializes all five elements in one statement, so the array contains the five specified values. The other options don’t meet the requirement: the second declares and allocates an array of length five but doesn’t assign explicit values to the elements; the third is just a declaration without initialization; the fourth provides only four elements.

Initializing an array in one statement means creating the array and supplying its elements at the same time using an initializer list. The number of values you put inside the braces determines the array’s length.

This option does exactly that: int arr[] = {1,2,3,4,5}; It creates the array and initializes all five elements in one statement, so the array contains the five specified values.

The other options don’t meet the requirement: the second declares and allocates an array of length five but doesn’t assign explicit values to the elements; the third is just a declaration without initialization; the fourth provides only four elements.