Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 ) What does the following statement do ? double [ ] array 1 = new double [ 1 0 ] ; A ) Declares

1) What does the following statement do?
double[] array1= new double[10];
A) Declares array1 to be a reference to an array of double values
B) Creates an instance of an array of 10 double values
C) Will allow valid subscripts in the range of 0-9
D) All of the above
2) Given that String[] str has been initialized, to get a copy of str[0] with all characters converted to upper case, use the following statement:
A) str.uppercase();
B) str[0].upperCase();
C) str.toUpperCase();
D) str[0].toUpperCase();
3) What will be returned from the following method?
public static float[] getValue(int x)
A) A float value
B) An array of float values
C) An integer
D) An array of integers
4) What would be the results after the following code was executed?
int[] x ={23,55,83,19};
int[] y ={36,78,12,24};
x = y;
y = x;
A) x[]={36,78,12,24} and y[]={23,55,83,19}
B) x[]={36,78,12,24} and y[]={36,78,12,24}
C) x[]={23,55,83,19} and y[]={23,55,83,19}
D) This is a compilation error.
5) What will be the result of executing the following code?
int[] x ={0,1,2,3,4,5};
A) An array of 6 values ranging from 0 through 5 and referenced by the variable x will be created.
B) A compilation error will occur.
C) The program will crash when it is executed.
D) The value of x[1] will be 0, x[2] will be 0, x[3] will be 0, x[4] will be 0, x[5] will be 0, and x[6] will be 0.
6) What would be the results of the following code?
int[] x ={55,33,88,22,99,
11,44,66,77};
int a =10;
if(x[2]> x[5])
a =5;
else
a =8;
A) a =5
B) a =8
C) a =10
D) This is a compilation error; you cannot compare array elements.
7) If numbers is a two-dimensional array, which of the following would give the length of row r?
A) numbers.length
B) numbers.length[r]
C) numbers[r].length[r]
D) numbers[r].length
8) Each array in Java has a public field named ________ that contains the number of elements in the array.
A) size
B) capacity
C) length
D) limit
Part B: State TRUE or FALSE:
1. An array can hold multiple values of several different data types simultaneously.
2. An ArrayList object automatically expands in size to accommodate the items stored in it.
3. Once an array is created, its size cannot be changed.
4. Java does not limit the number of dimensions that an array may have.
5. Objects in an array are accessed with subscripts, just like any other data type in an array.

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions