Ask Question

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)

+5
Answers (1)
  1. 22 May, 08:37
    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 & 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