Deck 9: Multidimensional Arrays and the Arraylist Class

ملء الشاشة (f)
exit full mode
سؤال
In an array of floats, each element contains a float value. What is true about the array?

A) Each element contains a double value.
B) The array is declared with a primitive type element.
C) The array requires three sets of empty brackets.
D) Float points to the location of the class.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The ArrayList class uses generics, which are:

A) parameterized types, meaning that the data type will be defined at the time a client class declares and instantiates an object of the class.
B) parameterized types, meaning that programmers must specify the class of the objects they use.
C) initialized types, meaning that programmers can design a code class without specifying the class of the objects they use.
D) None of these is correct.
سؤال
Why can you not print the contents of an array using only the array name?

A) Java does not support aggregate operations on multidimensional arrays.
B) Java does not support aggregate operations on single-dimensional arrays.
C) Each element in an array must be processed individually.
D) All of these are correct.
سؤال
Jessica wants to design a search engine for an online dictionary of software-related terms. Which class should she use?

A) Array class
B) Auto class
C) ArrayList class
D) Assign class
سؤال
In the following method, what type of object is returned (the answer has been omitted on purpose)?
Set( int index, E element )

A) It returns a boolean value.
B) It returns void.
C) It returns int.
D) It returns the data type of the ArrayList.
سؤال
The syntax for declaring a multidimensional array requires the brackets to follow the array name.
سؤال
The general pattern for processing the elements of column j of a two-dimensional array called arrayName uses a single for loop.
سؤال
The enhanced for loop enables looping through the ArrayList objects automatically.
سؤال
Multidimensional arrays are useful for which of the following?

A) You want to organize data along several dimensions.
B) You want to assign values after instantiating a list.
C) There is not a lot of data to store in memory.
D) None of these is correct.
سؤال
_____________ arrays allow us to represent data organized along n dimensions with a single array.

A) Floating
B) Dual
C) Multidimensional
D) None of these is correct.
سؤال
Why would you want to insert a comma between two array names in one statement?

A) It allows you to instantiate multiple multidimensional arrays of the same data type.
B) It allows you to declare multiple multidimensional arrays of different data types.
C) It allows you to declare multiple multidimensional arrays of the same data type.
D) It allows you to instantiate single arrays of the same data type.
سؤال
Which of the following are errors in this syntax declaring a two-dimensional array?
Datatype [4] [0] [3] arrayName:

A) The brackets must be empty.
B) There must be two brackets, not three.
C) The syntax must end in a semicolon, not a colon.
D) All of these are errors in the syntax.
سؤال
The syntax for instantiating a two-dimensional array, where rows are numberOfMonths, columns are numberOfStudents, the array name is starStudent, and the data type is double, can look something like this:
starStudent = new double [numberOfMonths][numberOfStudents];
سؤال
When a multidimensional array is instantiated, elements of arrays with numeric types are initialized to null.
سؤال
Why is it a good idea to check that the current column number is less than arrayName[i].length before attempting to access arrayName[i][j]?

A) Rows might have a different number of columns.
B) Accessing columns that do not exist will result in ArrayIndexOutofBoundsException at run time.
C) The column number must be within the range of 0 to arrayName[i].length - 1.
D) All of these are correct.
سؤال
In the outer for loop, using the condition i <= arrayName.length will result in:

A) a compiler error.
B) ArrayIndexOutOfBoundsException.
C) ArrayInBoundsException.
D) None of these is correct.
سؤال
After each completion of the inner loop when processing a row of a two-dimensional array, what must be done?

A) Initialize the processing variables for the current row.
B) Finish processing the current row.
C) Calculate the minimum value.
D) All of these are correct.
سؤال
This code would generate compiler errors.
for ( int i = 0; i < arrayName.length; i++ )
{
for ( int j = 0; j < arrayName[i].length; j++ )
{
// process element arrayName[i][j]
}
}
سؤال
To process elements of a three-dimensional array, use a double for loop.
سؤال
Programmers can reuse code from the ArrayList class.
سؤال
Use add( E element ) in the ArrayList class to update a list of slang terms with additional terms.
سؤال
How many empty sets of brackets are needed to declare an array?

A) One
B) Two
C) At least two sets are needed
D) It depends on how many dimensions are involved
سؤال
Initiating a two-dimensional array and then instantiating each row as a single-dimensional array will accomplish which of the following?

A) An array may have a different number of rows for each column.
B) An array may have a different number of columns for each row.
C) An array will have the same number of rows and columns.
D) There is not enough information to draw a conclusion.
سؤال
What is the purpose of this code?
For ( int i = 0; i < arrayName.length; i++ )
{
For ( int j = 0; j < arrayName[i].length; j++ )
{
// process element arrayName[i][j]
}
}

A) It is the general pattern for processing the elements of a two-dimensional array called arrayName in row-first, column-second order.
B) It is the general pattern for processing the elements of a single-dimensional array called arrayName in row-first, column-second order.
C) It is the general pattern for processing the elements of a two-dimensional array called arrayName in column-first, row-second order.
D) There is not enough information to draw a conclusion.
سؤال
What is the name of the method that returns the number of elements in an ArrayList object?

A) size
B) number
C) length
سؤال
In the header for ( Auto current : autos ):

A) Auto is an ArrayList.
B) current is an ArrayList.
C) autos is an ArrayList.
سؤال
In the header for ( Auto current : autos ):

A) Auto represents the Auto object that will be processed inside the loop body.
B) current represents the Auto object that will be processed inside the loop body.
C) autos represents the Auto object that will be processed inside the loop body.
سؤال
An ArrayList is not expandable.
سؤال
Three-dimensional arrays are not allowed in Java.
سؤال
We can store primitive data types in an ArrayList object.
سؤال
The ArrayList class uses generics.
سؤال
The name of the method that enables us to delete an element at a specified index in an ArrayList is __________.
سؤال
The __________ enables looping through an ArrayList object without using a counter and without using the get method to access each object.
سؤال
To access the element at row i and column j of a two-dimensional array named grades, we would use which of the following?

A) grades
B) grades[ i ][ j ]
C) grades[ j ][ i ]
D) grades( i )( j )
E) grades( j )( i )
سؤال
To access the number of rows in a two-dimensional array named grades, we would use which of the following?

A) grades
B) grades.size( )
C) grades.size
D) grades.length( )
E) grades.length
سؤال
To access the number of columns in row i of a two-dimensional array named grades, we would use which of the following?:

A) grades.length
B) grades[ i ].length
C) grades( i ).length
D) grades( i ).size
E) grades{ i }.length
سؤال
When processing all the elements of row i of a two-dimensional array named grades using a for loop with variable j, what is the condition of the for loop?

A) j < length
B) j < grades.length
C) j <= grades.length
D) j < grades[i].length
E) j <= grades[i].length
سؤال
The ArrayList class belongs to which package?

A) java.lang
B) java.text
C) java.util
D) java.list
E) java.array
سؤال
How do you declare an ArrayList object reference of Book objects named books?

A) ArrayList< > books;
B) ArrayList books;
C) ArrayList books;
D) ArrayList books;
E) ArrayList Book;
سؤال
An ArrayList object reference of Book objects named books has already been declared. How do you instantiate it using the ArrayList default constructor?

A) books = new ArrayList( );
B) books = new ArrayList( );
C) books = new ArrayList( );
D) books = new Book( );
E) books = new Book( );
سؤال
When declaring a two-dimensional array, we use two sets of square brackets.
سؤال
We can instantiate a two-dimensional array by assigning values when the array is declared.
سؤال
In a two-dimensional array, the number of elements in each row must be the same for every row.
سؤال
We cannot combine the declaration and instantiation of a multidimensional array.
سؤال
To process all the elements of a two-dimensional array, we use a double loop.
سؤال
We can pass a two-dimensional array parameter to a method.
سؤال
A method cannot return a two-dimensional array parameter.
سؤال
A two-dimensional array is an array of __________.
سؤال
When processing the elements of a two-dimensional array one row at a time, we should __________ the row processing variables before processing each row.
سؤال
An ArrayList automatically __________ its capacity as needed.
سؤال
If we want to store primitive data types in an ArrayList object, then we should use __________ classes.
سؤال
The ArrayList class uses generics; thus, the data type used is defined at a time the __________ class declares and instantiates an ArrayList object.
سؤال
The name of the method that enables us to append an element to the end of an ArrayList is __________.
سؤال
Identify how to instantiate a two-dimensional array by assigning initial values when the array is declared.
سؤال
Compare the function of the following two statements:
arrayName.length
arrayName[i].length
سؤال
When processing all the elements of a column of a two-dimensional array, what possible runtime error do we have to worry about?
سؤال
Simeon wants to keep track of his batting average for each day of each week of the next baseball season. Evaluate what is wrong with this code and recommend an alternative code.
double [ ] battingAverage;
سؤال
Which keyword would you add to this code to instantiate the array, allocating memory for the array? Provide the updated code.
arrayName = datatype [exp1][exp2];
سؤال
Theorize why the following code would generate compiler errors:
Auto [4][12] cars;
سؤال
Theorize why the following code would generate compiler errors:
int [ ][ ] highTemps = new int [2][3];
highTemps = { { 89, 85, 98 },
{ 88, 90, 92 } };
سؤال
A code written to analyze the average high temperatures in four cities for June, July, and August was set up so that the cities are the rows. Evaluate the results of this code:
avgHighTemps[2][0] = 75.2; // row 2
avgHighTemps[2][1] = 82.3;
avgHighTemps[2][2] = 78.5;
avgHighTemps[2][3] = 71.6;
سؤال
Compare lines 22-23 with 27-28 and explain how the results will differ.
21 System.out.println( "\nUsing the enhanced for loop:" );
22 for ( Integer currentInteger : list )
23 System.out.print( currentInteger + "\t" );
24 System.out.println( );
25
26 System.out.println( "\nUsing unboxing and enhanced for loop:" );
27 for ( int currentInt : list ) // unboxing
28 System.out.print( currentInt + "\t" );
29 System.out.println( );
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/62
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Multidimensional Arrays and the Arraylist Class
1
In an array of floats, each element contains a float value. What is true about the array?

A) Each element contains a double value.
B) The array is declared with a primitive type element.
C) The array requires three sets of empty brackets.
D) Float points to the location of the class.
B
2
The ArrayList class uses generics, which are:

A) parameterized types, meaning that the data type will be defined at the time a client class declares and instantiates an object of the class.
B) parameterized types, meaning that programmers must specify the class of the objects they use.
C) initialized types, meaning that programmers can design a code class without specifying the class of the objects they use.
D) None of these is correct.
A
3
Why can you not print the contents of an array using only the array name?

A) Java does not support aggregate operations on multidimensional arrays.
B) Java does not support aggregate operations on single-dimensional arrays.
C) Each element in an array must be processed individually.
D) All of these are correct.
D
4
Jessica wants to design a search engine for an online dictionary of software-related terms. Which class should she use?

A) Array class
B) Auto class
C) ArrayList class
D) Assign class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
5
In the following method, what type of object is returned (the answer has been omitted on purpose)?
Set( int index, E element )

A) It returns a boolean value.
B) It returns void.
C) It returns int.
D) It returns the data type of the ArrayList.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
6
The syntax for declaring a multidimensional array requires the brackets to follow the array name.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
7
The general pattern for processing the elements of column j of a two-dimensional array called arrayName uses a single for loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
8
The enhanced for loop enables looping through the ArrayList objects automatically.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
9
Multidimensional arrays are useful for which of the following?

A) You want to organize data along several dimensions.
B) You want to assign values after instantiating a list.
C) There is not a lot of data to store in memory.
D) None of these is correct.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
10
_____________ arrays allow us to represent data organized along n dimensions with a single array.

A) Floating
B) Dual
C) Multidimensional
D) None of these is correct.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
11
Why would you want to insert a comma between two array names in one statement?

A) It allows you to instantiate multiple multidimensional arrays of the same data type.
B) It allows you to declare multiple multidimensional arrays of different data types.
C) It allows you to declare multiple multidimensional arrays of the same data type.
D) It allows you to instantiate single arrays of the same data type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following are errors in this syntax declaring a two-dimensional array?
Datatype [4] [0] [3] arrayName:

A) The brackets must be empty.
B) There must be two brackets, not three.
C) The syntax must end in a semicolon, not a colon.
D) All of these are errors in the syntax.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
13
The syntax for instantiating a two-dimensional array, where rows are numberOfMonths, columns are numberOfStudents, the array name is starStudent, and the data type is double, can look something like this:
starStudent = new double [numberOfMonths][numberOfStudents];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
14
When a multidimensional array is instantiated, elements of arrays with numeric types are initialized to null.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
15
Why is it a good idea to check that the current column number is less than arrayName[i].length before attempting to access arrayName[i][j]?

A) Rows might have a different number of columns.
B) Accessing columns that do not exist will result in ArrayIndexOutofBoundsException at run time.
C) The column number must be within the range of 0 to arrayName[i].length - 1.
D) All of these are correct.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
16
In the outer for loop, using the condition i <= arrayName.length will result in:

A) a compiler error.
B) ArrayIndexOutOfBoundsException.
C) ArrayInBoundsException.
D) None of these is correct.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
17
After each completion of the inner loop when processing a row of a two-dimensional array, what must be done?

A) Initialize the processing variables for the current row.
B) Finish processing the current row.
C) Calculate the minimum value.
D) All of these are correct.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
18
This code would generate compiler errors.
for ( int i = 0; i < arrayName.length; i++ )
{
for ( int j = 0; j < arrayName[i].length; j++ )
{
// process element arrayName[i][j]
}
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
19
To process elements of a three-dimensional array, use a double for loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
20
Programmers can reuse code from the ArrayList class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
21
Use add( E element ) in the ArrayList class to update a list of slang terms with additional terms.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
22
How many empty sets of brackets are needed to declare an array?

A) One
B) Two
C) At least two sets are needed
D) It depends on how many dimensions are involved
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
23
Initiating a two-dimensional array and then instantiating each row as a single-dimensional array will accomplish which of the following?

A) An array may have a different number of rows for each column.
B) An array may have a different number of columns for each row.
C) An array will have the same number of rows and columns.
D) There is not enough information to draw a conclusion.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
24
What is the purpose of this code?
For ( int i = 0; i < arrayName.length; i++ )
{
For ( int j = 0; j < arrayName[i].length; j++ )
{
// process element arrayName[i][j]
}
}

A) It is the general pattern for processing the elements of a two-dimensional array called arrayName in row-first, column-second order.
B) It is the general pattern for processing the elements of a single-dimensional array called arrayName in row-first, column-second order.
C) It is the general pattern for processing the elements of a two-dimensional array called arrayName in column-first, row-second order.
D) There is not enough information to draw a conclusion.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
25
What is the name of the method that returns the number of elements in an ArrayList object?

A) size
B) number
C) length
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
26
In the header for ( Auto current : autos ):

A) Auto is an ArrayList.
B) current is an ArrayList.
C) autos is an ArrayList.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
27
In the header for ( Auto current : autos ):

A) Auto represents the Auto object that will be processed inside the loop body.
B) current represents the Auto object that will be processed inside the loop body.
C) autos represents the Auto object that will be processed inside the loop body.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
28
An ArrayList is not expandable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
29
Three-dimensional arrays are not allowed in Java.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
30
We can store primitive data types in an ArrayList object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
31
The ArrayList class uses generics.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
32
The name of the method that enables us to delete an element at a specified index in an ArrayList is __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
33
The __________ enables looping through an ArrayList object without using a counter and without using the get method to access each object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
34
To access the element at row i and column j of a two-dimensional array named grades, we would use which of the following?

A) grades
B) grades[ i ][ j ]
C) grades[ j ][ i ]
D) grades( i )( j )
E) grades( j )( i )
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
35
To access the number of rows in a two-dimensional array named grades, we would use which of the following?

A) grades
B) grades.size( )
C) grades.size
D) grades.length( )
E) grades.length
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
36
To access the number of columns in row i of a two-dimensional array named grades, we would use which of the following?:

A) grades.length
B) grades[ i ].length
C) grades( i ).length
D) grades( i ).size
E) grades{ i }.length
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
37
When processing all the elements of row i of a two-dimensional array named grades using a for loop with variable j, what is the condition of the for loop?

A) j < length
B) j < grades.length
C) j <= grades.length
D) j < grades[i].length
E) j <= grades[i].length
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
38
The ArrayList class belongs to which package?

A) java.lang
B) java.text
C) java.util
D) java.list
E) java.array
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
39
How do you declare an ArrayList object reference of Book objects named books?

A) ArrayList< > books;
B) ArrayList books;
C) ArrayList books;
D) ArrayList books;
E) ArrayList Book;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
40
An ArrayList object reference of Book objects named books has already been declared. How do you instantiate it using the ArrayList default constructor?

A) books = new ArrayList( );
B) books = new ArrayList( );
C) books = new ArrayList( );
D) books = new Book( );
E) books = new Book( );
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
41
When declaring a two-dimensional array, we use two sets of square brackets.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
42
We can instantiate a two-dimensional array by assigning values when the array is declared.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
43
In a two-dimensional array, the number of elements in each row must be the same for every row.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
44
We cannot combine the declaration and instantiation of a multidimensional array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
45
To process all the elements of a two-dimensional array, we use a double loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
46
We can pass a two-dimensional array parameter to a method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
47
A method cannot return a two-dimensional array parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
48
A two-dimensional array is an array of __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
49
When processing the elements of a two-dimensional array one row at a time, we should __________ the row processing variables before processing each row.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
50
An ArrayList automatically __________ its capacity as needed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
51
If we want to store primitive data types in an ArrayList object, then we should use __________ classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
52
The ArrayList class uses generics; thus, the data type used is defined at a time the __________ class declares and instantiates an ArrayList object.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
53
The name of the method that enables us to append an element to the end of an ArrayList is __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
54
Identify how to instantiate a two-dimensional array by assigning initial values when the array is declared.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
55
Compare the function of the following two statements:
arrayName.length
arrayName[i].length
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
56
When processing all the elements of a column of a two-dimensional array, what possible runtime error do we have to worry about?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
57
Simeon wants to keep track of his batting average for each day of each week of the next baseball season. Evaluate what is wrong with this code and recommend an alternative code.
double [ ] battingAverage;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
58
Which keyword would you add to this code to instantiate the array, allocating memory for the array? Provide the updated code.
arrayName = datatype [exp1][exp2];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
59
Theorize why the following code would generate compiler errors:
Auto [4][12] cars;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
60
Theorize why the following code would generate compiler errors:
int [ ][ ] highTemps = new int [2][3];
highTemps = { { 89, 85, 98 },
{ 88, 90, 92 } };
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
61
A code written to analyze the average high temperatures in four cities for June, July, and August was set up so that the cities are the rows. Evaluate the results of this code:
avgHighTemps[2][0] = 75.2; // row 2
avgHighTemps[2][1] = 82.3;
avgHighTemps[2][2] = 78.5;
avgHighTemps[2][3] = 71.6;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
62
Compare lines 22-23 with 27-28 and explain how the results will differ.
21 System.out.println( "\nUsing the enhanced for loop:" );
22 for ( Integer currentInteger : list )
23 System.out.print( currentInteger + "\t" );
24 System.out.println( );
25
26 System.out.println( "\nUsing unboxing and enhanced for loop:" );
27 for ( int currentInt : list ) // unboxing
28 System.out.print( currentInt + "\t" );
29 System.out.println( );
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 62 في هذه المجموعة.