Ask Question
6 November, 17:06

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.

+1
Answers (1)
  1. 6 November, 19:00
    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?
Get 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 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