Knowee
Questions
Features
Study Tools

Tom wants to store the temperature of 15 cities. Help him to declare the array to do this.Which of the following declaration meets his requirement?           Select one:a.float temperature[]=new float(15);b.float temperature(15)c.float temperature[]=new temperature[15];d.float temperature[15];e.float temperature[]=new float[15];

Question

Tom wants to store the temperature of 15 cities. Help him to declare the array to do this.Which of the following declaration meets his requirement?           Select one:a.float temperature[]=new float(15);b.float temperature(15)c.float temperature[]=new temperature[15];d.float temperature[15];e.float temperature[]=new float[15];

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct declaration to meet Tom's requirement is:

e. float temperature[]=new float[15];

This statement declares an array in Java named 'temperature' that can store 15 float values. The 'new' keyword is used to allocate memory for the array.

Similar Questions

Suppose you are developing a program to calculate the average temperature for each month of the year. You need to store the average temperatures for each month in an array and display them on the screen. Which of the following options correctly initializes an array named averageTemperatures to store the average temperatures for each month and displays them on the screen in Java?

You are working on a program that needs to keep track of many values at the same time. Which of the following would you use?answerA variableA floatA constantAn array

Which of the following declaration is illegal?a.int a = 0, b = 1, c = 2; int array[3] = {a, b, c};b.int size = 3; int array[size];c.int size = 3; int array[size] = {1, 2, 3};d.In appropriate

Choose the correct way to declare 2D array.a.int x[3][4] = {0, 1 ,2 ,3 ,4 , 5 , 6 , 7 , 8 , 9 , 10 , 11};b.int x[3] = {0, 1 ,2 ,3 ,4 , 5 , 6 , 7 , 8 , 9 , 10 , 11}c.int x[4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}};d.None of the above

Which of the following syntax correctly declares an Array in C/C++?int geeks;array geeks[20];geeks{20};int geeks[20];

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.