Ask Question

7.1 Write statements that create the following arrays: A 100-element int array referenced by the variable employeeNumbers. final int employeeNumbers = 100; int [] numbers = new int[employeeNumbers]; B 25-element double array referenced by the variable payRates. final double payRates = 25; int[] numbers = new int [Double] C. A 14-element float array referenced by the variable miles. float[] miles = 14; D 1000-element char array referenced by the variable char[] letters = new char[1000]; 7.2 What's wrong with the following array declarations? int[] readings = new int[-1]; double[] measurements = new double[4.5]; There should be no negs. 7.3 What would the valid subscript values be in a four-element array of doubles? 7.4 What is the difference between an array's size declarator and a subscript? My: idk 7.5 What does it mean for a subscript to be out-of-bounds? My: Declares error

+2
Answers (1)
  1. 18 August, 01:29
    0
    A. int [ ] numbers = new int[employeeNumbers];

    B. double[ ] numbers = new double[payRates];

    C. float[ ] miles = new float[14];

    D. char[ ] letters = new char[1000];

    7.2 Size of array cannot be negative

    Size of array should be a positive integer and not decimal.

    7.4 The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element in an array.

    7.5 subscript to be out-of-bound means the specified integer is not within the range of the length of the array.

    Explanation:

    The question has answer given for some. I guess the explanation is what is needed.

    A. The general format of creating an array is:

    data type[] arrayRefVar=new datatype[size];

    In this case, the datatype is int, arrayRefVar is numbers, size is employeeNumbers. The size was already initialised to 100 (employeeNumber).

    B. A wrong datatype was used.

    double[ ] numbers = new double[payRates];

    would create an array of size 25 which is the payRates with types double.

    C. The array was re-written using the general format of creating an array is:

    data type[] arrayRefVar=new datatype[size];

    D. The array was correctly defined.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “7.1 Write statements that create the following arrays: A 100-element int array referenced by the variable employeeNumbers. final int ...” 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