Ch 7- Arrays and the ArrayList Class

Given that String str has been initialized, to get a copy of str with all characters converted to upper case, use the following statement:

str.toUpperCase( );

Which of the following is a valid declaration for a ragged array, after which you would declare each row?
A. int ragged = new int;
B. int ragged = new int;
C. int ragged = new int;
D. int ragged = new int;

C. int ragged = new int;

If numbers is a two-dimensional array, which of the following would give the length of row r?

numbers.length

What would be the results of the following code?

final int SIZE = 25;
int array1 = new int;

... // Code that will put values in array1

int value = 0;
for(int a = 0; a < array.lenth; a++)
{
value += array1;
}

value contains the highest value in array1

T or F: An ArrayList object automatically expands in size to accommodate the items stored in it.

True

Which of the following is a correct method header for receiving a two-dimensional array as an argument?
A. public static void passArray(int intArray)
B. public static void passArray(int intArray)
C. public static void passArray(int, intArray)
D. public static void passArray(int, intintArray)

B. public static void passArray(int intArray)

T or F: Java limits the number of dimensions that an array may have to 15.

False

What will be the value of x after the following code has been executed?

final int SUB = 12;
int x = new int;
int y = 100;
for(int i = 0; i < SUB; i++)
{
x = y;
y+= 10;
}

180

The ArrayList class is in this package.

java.util

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-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 will be 0, x will be 0, x will be 0, x will be 0, x will be 0, and x will be 0

A. An array of 6 values ranging from 0-5 and referenced by the variable x will be created

What does the following statement do?

double[] array1 = new double;

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 these

D. All of these

T or F: If a and b are two integer arrays, the expression a == b compares the array contents.

False

What is the value of scores in the following array?

int scores = { {88, 80, 79, 92}, {75, 84, 93, 80}, {98, 95, 92, 94}, {91, 84, 88, 96} };

94

You can use this ArrayList class method to insert an item at a specific location in an ArrayList.

add

You can use this ArrayList class method to replace an item at a specific location in an ArrayList.

add???

What will be the results of the following code?

final int ARRAY_SIZE = 5;
float x = float;
for(int i = 1; i <= ARRAY_SIZE; i++)
{
x = 10.0;
}

An error will occur when the program runs

The following statement creates an ArrayList object. What is the purpose of the <String> notation?

ArrayList<String> arr = new ArrayList<String>( );

A. It specifies that only String objects may be stored in the ArrayList object
B. It specifies that the get method will return only String objects
C. It specifies that String objects may not be stored in the ArrayList object
D. It specifies that everything stored in the ArrayList object will be converted to a String

A. It specifies that only String objects may be stored in the ArrayList object

How many rows and how many columns are in the points array, declared here:

int points = new int;

10 rows and 20 columns

The sequential search algorithm:

Uses a loop to sequentially step through an array, starting with the first element

T or F: When an array of objects is declared, but not initialized, the array values are set to null.

True

A ragged array is:

A two-dimensional array when the rows are of different lengths

T or F: Any items typed on the command-line, separated by space, after the name of the class are considered to be one or more arguments that are to be passed into the main method.

True

T or F: To compare the contents of two arrays, you must compare the elements of the two arrays.

True

T or F: The purpose of the sequential search algorithm is to rearrange the elements of an array so they appear in order from the lowest value to the highest value.

False

A search algorithm:

Is a way to locate a specific item in a larger collection of data

Ch 7- Arrays and the ArrayList Class - Subjecto.com

Ch 7- Arrays and the ArrayList Class

Your page rank:

Total word count: 791
Pages: 3

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

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:

str[0].toUpperCase( );

Which of the following is a valid declaration for a ragged array, after which you would declare each row?
A. int[ ] ragged = new int[5];
B. int[ ][ ] ragged = new int[5][6];
C. int[ ][ ] ragged = new int[5][ ];
D. int[ ][ ] ragged = new int[ ][5];

C. int[ ][ ] ragged = new int[5][ ];

If numbers is a two-dimensional array, which of the following would give the length of row r?

numbers[r].length

What would be the results of the following code?

final int SIZE = 25;
int[ ] array1 = new int[SIZE];

… // Code that will put values in array1

int value = 0;
for(int a = 0; a < array.lenth; a++)
{
value += array1[a];
}

value contains the highest value in array1

T or F: An ArrayList object automatically expands in size to accommodate the items stored in it.

True

Which of the following is a correct method header for receiving a two-dimensional array as an argument?
A. public static void passArray(int[1,2] intArray)
B. public static void passArray(int [ ][ ] intArray)
C. public static void passArray(int[1],[2] intArray)
D. public static void passArray(int[ ], int[ ]intArray)

B. public static void passArray(int [ ][ ] intArray)

T or F: Java limits the number of dimensions that an array may have to 15.

False

What will be the value of x[8] after the following code has been executed?

final int SUB = 12;
int[ ] x = new int[SUB];
int y = 100;
for(int i = 0; i < SUB; i++)
{
x[i] = y;
y+= 10;
}

180

The ArrayList class is in this package.

java.util

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-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

A. An array of 6 values ranging from 0-5 and referenced by the variable x will be created

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 these

D. All of these

T or F: If a[ ] and b[ ] are two integer arrays, the expression a == b compares the array contents.

False

What is the value of scores[2][3] in the following array?

int [ ] [ ] scores = { {88, 80, 79, 92}, {75, 84, 93, 80}, {98, 95, 92, 94}, {91, 84, 88, 96} };

94

You can use this ArrayList class method to insert an item at a specific location in an ArrayList.

add

You can use this ArrayList class method to replace an item at a specific location in an ArrayList.

add???

What will be the results of the following code?

final int ARRAY_SIZE = 5;
float [ ] x = float[ARRAY_SIZE];
for(int i = 1; i <= ARRAY_SIZE; i++)
{
x[i] = 10.0;
}

An error will occur when the program runs

The following statement creates an ArrayList object. What is the purpose of the <String> notation?

ArrayList<String> arr = new ArrayList<String>( );

A. It specifies that only String objects may be stored in the ArrayList object
B. It specifies that the get method will return only String objects
C. It specifies that String objects may not be stored in the ArrayList object
D. It specifies that everything stored in the ArrayList object will be converted to a String

A. It specifies that only String objects may be stored in the ArrayList object

How many rows and how many columns are in the points array, declared here:

int [ ][ ] points = new int[10][20];

10 rows and 20 columns

The sequential search algorithm:

Uses a loop to sequentially step through an array, starting with the first element

T or F: When an array of objects is declared, but not initialized, the array values are set to null.

True

A ragged array is:

A two-dimensional array when the rows are of different lengths

T or F: Any items typed on the command-line, separated by space, after the name of the class are considered to be one or more arguments that are to be passed into the main method.

True

T or F: To compare the contents of two arrays, you must compare the elements of the two arrays.

True

T or F: The purpose of the sequential search algorithm is to rearrange the elements of an array so they appear in order from the lowest value to the highest value.

False

A search algorithm:

Is a way to locate a specific item in a larger collection of data

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending