Ask Question
19 October, 20:51

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.

+2
Answers (1)
  1. 20 October, 00:20
    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 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