Question: Qn1) Determine whether the following array declarations are valid. If a declaration is invalid, give a correct declaration. a. int[75] list; b. int size; double[]

Qn1) Determine whether the following array declarations are valid. If a declaration is invalid, give a correct declaration. a. int[75] list;

b. int size; double[] list = new double[size];

c. int[] test = new int[-10];

d. double[] sales = new double[40.5];

e. scores double = new double[50]; Qn2 a. What would be a valid range for the index of an array of size 50? Write Java statements that do the following : b. Declare an array alpha of 15 elements of type int.

c. Output the value of the tenth element of the array alpha.

d. Set the value of the fth element of the array alpha to 35.

e. Set the value of the ninth element of the array alpha to the sum of the sixth and thirteenth elements of the array alpha.

f. Set the value of the fourth element of the array alpha to three times the value of the eighth element, minus 57.

g. Output alpha so that ve elements per line are printed. Qn3 Write Java statements for performing the following tasks with a 2D array named values that has 20 rows and 30 columns. a. Declare the array values.

b. Fill all entries with 0.

c. Fill elements alternately with 0s and 1s in a checkerboard pattern.

d. Fill only the elements at the top and bottom row with zeroes.

e. Compute the sum of all elements.

f. Print the array in tabular form

(Hint: you could use the method System.out.printf()).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!