Ask Question
7 September, 07:52

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

+2
Answers (1)
  1. 7 September, 08:01
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers