Ask Question
8 June, 12:19

Which of the following initializer lists would correctly set the elements of array n?

a. int[] n = { 1, 2, 3, 4, 5 };.

b. array n[ int ] = { 1, 2, 3, 4, 5 };.

c. int n[ 5 ] = { 1; 2; 3; 4; 5 };.

d. int n = new int (1, 2, 3, 4, 5);.

+5
Answers (1)
  1. 8 June, 13:48
    0
    The correct answer to this question is option (a).

    Explanation:

    In the programming language (java) the syntax for declaring, initializing single denominational array can be given as:

    Syntax:

    datatype array[] arrayname; / / declare the array

    Example: int [] a;

    a = new int[5]; / / create the array

    int [] n = {2,5,7,9,3}; / / initialize all elements

    Or

    a[0] = 2;

    a[1] = 22;

    a[2] = 12;

    a[3] = 20;

    a[4] = 23;

    In the above we define the way to initialize the array. So the correct way to set array element is option (a).
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Which of the following initializer lists would correctly set the elements of array n? a. int[] n = { 1, 2, 3, 4, 5 };. b. array n[ int ] = ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers