Ask Question

To initialize a String array names to store the three Strings "Huey", "Duey" and "Louie", you would do:

a) String names = {"Huey", "Duey", "Louie"};

b) String[ ] names = {"Huey", "Duey", "Louie"};

c) String[ ] names = new String{"Huey", "Duey", "Louie"};

d) String names[3] = {"Huey", "Duey", "Louie"};

e) String names; names[0] = "Huey"; names[1] = "Duey"; names[2] = "Louie";

+1
Answers (1)
  1. 19 June, 17:54
    0
    B) String[ ] names = {"Huey", "Duey", "Louie"};

    Explanation:

    In Java programming language, arrays are declared by first Writing the data type of the elements that will be stored in the array, in this case String. This is followed by square brackets indicating that the variable is an array, followed by the array name which must follow the rules of naming variables. The example below is a valid declaration of an array.

    String[ ] names;

    Next in java we can initialize the elements either by using the new keyword and specifying the length of the array to create the array in memory like this;

    String[ ] names = new String[3];

    Or we initialize by assigning values in curly braces seperated by commas like in the question ablove.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “To initialize a String array names to store the three Strings "Huey", "Duey" and "Louie", you would do: a) String names = {"Huey", "Duey", ...” 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