Ask Question

Which of the following statements about creating arrays and initializing their elements is false?

a. The new keyword should be used to create an array.

b. When an array is created, the number of elements must be placed in square brackets following the type of element being stored.

c. The elements of an array of integers have a value of null before they are initialized.

d. A for loop is commonly used to set the values of the elements of an array.

+2
Answers (1)
  1. 14 November, 03:07
    0
    b. When an array is created, the number of elements must be placed in square brackets following the type of element being stored.

    Explanation:

    In Java an uninitialized array contains null values. Thus statement c is true as well.

    Also generally for initializing and displaying array elements a for loop is used. Hence statement d is also correct.

    In Java syntax for declaring an array is as follows:

    Array declaration:

    type [] array_name;

    Array instantiation (memory allocation):

    type [] array_name = new array_name [size of array];

    From the above it can be seen that the statement a is true and statement b is false as number of elements in array are not mentioned after the type.

    Hence the correct answer is b.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Which of the following statements about creating arrays and initializing their elements is false? a. The new keyword should be used to ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers