Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

What is the purpose of an employee stock ownership plan (ESOP)?

Answered: 1 week ago