Ask Question
10 May, 22:32

Suppose you have the following declaration. char[] nameList = new char[100]; Which of the following range is valid for the index of the array nameList. (i) 1 through 100 (ii) 0 through 1001. Both are invalid2. Only (i) 3. None of these4. Only (ii)

+1
Answers (1)
  1. 10 May, 23:28
    0
    4. Only (ii)

    Explanation:

    The declaration of the array can be of two types:

    1. int a[100];

    2. int[] a = new int[100];

    The general thing about an array is that whenever we want to undergo traversal in an array, we always have to start from the 0th position as the size of the array may be a whole number (let us say 10). So, to undergo traversal in an array, we start from 0 to n-1 (in this case 9) such that it covers the size of the array.

    The size of an array can be finite or infinite. The general rule is it starts from 0 to n-1 where n is the size of the array. In the above example, the range of the index of the array will be 0 through 100 and not 1 through 100.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Suppose you have the following declaration. char[] nameList = new char[100]; Which of the following range is valid for the index of the ...” 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