Ask Question
24 September, 15:32

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);.

+1
Answers (1)
  1. 24 September, 15:53
    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?
Find 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 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