Question
QUESTION 1 Answer questions based on the following code: int[] x = new int [10]; 1. x is a reference variable to an array. Its
QUESTION 1
Answer questions based on the following code:
int[] x = new int [10];
1. x is a reference variable to an array. Its dimension is _____. (use numeric value)
2. x.length has a value of _____. (use numeric value)
3. The array stores ______ values of ______ type. (numeric value for first; case sensitive Java type for second)
4. The first element, x[___], is initialized to ____. (numeric values)
5. The index to the last element is ____. (numeric value)
QUESTION 2
After the following code finishes executing, the variable result has a value of ___. (numeric value)
int result=0;
int[] x = {10,20,30};
for (int i=0; i result += x[i];}QUESTION 3
After the following code executes, the values in the array are ___, ____, ____ (numeric values).
int v[] = new int[3];for (int i=1; i v[i] = v[i-1] + 1;}QUESTION 4
Given this following code:
int[][] a = new int[2][3];
Indicate all statements that are true.
A) a[0].length has a value of 2.
B) a.length has a value of 2.
C) Variable a has a primitive data type.
D) a[2][3] is a cell of array a with a value of 0.
E) Array a is a two dimensional array.
F) a[0][1] is a cell of array a with a value of 0.
QUESTION 5
Indicate all true statements about arrays in Java.
A) It is impossible to create a 5 dimensional array in Java because maximum dimension is limited to 3.
B)Array index starts from 1.
C) An array variable is of a reference type even if its elements have a primitive type.
D) When an array is created, all cells are initialized with default value according to element type.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started