Java Programming Multiple Choice. Part I. (20 pts.) l. Which of the following st
ID: 3817665 • Letter: J
Question
Java Programming Multiple Choice.
Part I. (20 pts.) l. Which of the following statements creates a 2D array with 50 rows and 100 columns to hold double values? a. double [][]d new double [J[Js b. double ld new double [50] [100]: c. double ld new double [1000050]: d. double [][]d new double [new doublej[50] [100]: 2. What is the best description of the structure created by the code? int III l a new int 13ll l; al0 new int 4 a il new int 15l; al new int 161; a. There is a 2D array of 3 rows and 6 columns. b. There are three 2D arrays where the first is 3x4, the second is 3x5, and the third is 3x6. c. There is a 2D array of 3 rows where the first row can hold 4 values, the second row can hold 5 values, and the third row can hold 6 values. d. There is a 2D array of 3 columns where the first column can hold 4 values, the second column can hold 5 values, and the third column can hold 6 values. The following two questions use the recursive function below public static int mystery (int x) if (x 1) return 1 else return 5 mystery (x-1); 3. What is the return value from the function call: mystery (3)? 4. The base case occurs when parameter x has value(s)Explanation / Answer
Ans. 1 is option b
syntax to define 2d array is
<datatype> [][] <variable_name>= new <datatype> [rowsize][columnsize];
therefore double [][]d = new double[50][100] is the correct answer with 50 rows and 100 columns.
Ans2. correct answer is option c is correct
This is how we can create a two dimensional array where individual one dimensional arrays has different length,
Hence option c .there is a 2d array of 3 rows where the first row hold 4 values, the second row can hold 5 values, and the third row can hold 6 values.
Ans3. answer is 25
function call mystery(3):
x!=1
hence 5*mystery(x-1) which means 5* mystery (2)
function call mystery(2):
hence 5*mystery(x-1) which means 5* mystery (1)
function call mystery(2):
return 1.
It can be written as
5* mystery (2) { result of mystery(3)}
5* mystery (1) { result of mystery(2)}
1 { result of mystery(1)}
that is 5*5*1
whic is equal to 25
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.