Ask Question
1 February, 07:44

An array of stringobjects that will hold 5 names would be declared using which statement?

A) string names[5];

B) string names (5);

C) string names5;

D) String[5] names;

E) None of these will work.

+3
Answers (1)
  1. 1 February, 07:51
    0
    E) None of these will work

    Explanation:

    Option A, string names[5] will not work because the keyword String is not properly capitalized. Generally, arrays are declared and initialized. This is accomplished in Java Programming language with the new keyword or by assigning initial values to the array in a pair of braces. A valid declaration and initialization for the above question will be any of these two;

    String [ ] names = new String [5];

    String [ ] namesTwo = {"John", "James", "Jonathan","John", "Jabez"};

    In the first example a new array object is created with the new keyword with a provision to hold five elements

    In the second example the array is created and and assigned five elements.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “An array of stringobjects that will hold 5 names would be declared using which statement? A) string names[5]; B) string names (5); C) ...” 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