Deck 9: Arrays

ملء الشاشة (f)
exit full mode
سؤال
Suppose list is a one-dimensional array, wherein each component is of the type int. The following for loop correctly finds the sum of the elements of list.int sum = 0; for (int num : list)
sum = sum + num;
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
In a method call statement, when passing an array as an actual parameter, you use only its name.
سؤال
The statementint[] list = new int[15];creates list to be an array of 14 components because array index starts at 0.
سؤال
Given the declarationdouble[] numList = new double[20];the statementnumList[12] = numList[5] + numList[7];updates the content of the thirteenth component of the array numList.
سؤال
Java stores two-dimensional arrays in a row order form in computer memory.
سؤال
A single array can hold components of many different data types.
سؤال
When an array object is instantiated, its components are initialized to their default values.
سؤال
If a method has both a variable length formal parameter and other types of formal parameters, then the variable length formal parameter must be the first formal parameter of the formal parameter list.
سؤال
In row processing, a two-dimensional array is processed one row at a time.
سؤال
The array index can be any nonnegative integer less than the array size.
سؤال
Suppose that you have the following declaration.int[] alpha = new int[50];
int[][] beta = new int[10][5];In this declaration, the array alpha has more components than the array beta.
سؤال
Given the declaration int[] list = new int[50];the statementSystem.out.println(list[0] + "..." + list[49]);outputs all 50 components of the array list.
سؤال
If an array index is less than or equal to zero, an InvalidIndexException exception is thrown.
سؤال
Arrays have a fixed number of elements.
سؤال
When a boolean array object is instantiated, its components are initialized to false.
سؤال
In column processing, a two-dimensional array is processed one column at a time.
سؤال
You can create an array of reference variables to manipulate objects.
سؤال
The base address of an array is the memory location of the first array component.
سؤال
Only one-dimensional arrays can be passed as parameters.
سؤال
The following statement creates alpha to be a two-dimensional array of 35 components. int[][] alpha = new int[20][15];
سؤال
int[] list = {1, 3, 5, 7};(int i = 0; i < list.length; i++)
If (list[i] > 5)
System.out.println(i + " " + list[i]);Which indices are in bounds for the array list, given the declaration in the accompanying figure?

A) 0, 1, 2, 3
B) 1, 2, 3, 4
C) 1, 3, 5, 7
D) 0, 1, 3, 5
سؤال
The statement dataType[][][] arrayName; would declare a two-dimensional array.
سؤال
char[][] table = new char[10][5];How many columns are in the array seen in the accompanying figure?

A) 0
B) 5
C) 10
D) 15
سؤال
char[][] table = new char[10][5];What is the value of table[2].length?

A) 0
B) 5
C) 10
D) 15
سؤال
The method size in the class Vector returns the number of elements in the vector.
سؤال
Suppose you have the following declaration.double[] salesData = new double[500];Which of the following range is valid for the index of the array salesData.
(i) 0 through 500
(ii) 0 through 499

A) Only (i)
B) Only (ii)
C) Both are invalid
D) None of these
سؤال
Which of the following is the array subscripting operator in Java?

A) .
B) {}
C) new
D) []
سؤال
int[] numList = new int[50];for (int i = 0; i <50; i++)
NumList[i] = 2 * i;
Num[10] = -20;
Num[30] = 8;
How many components are in the array numList seen in the accompanying figure?

A) 0
B) 30
C) 49
D) 50
سؤال
Vectors can be used to implement lists.
سؤال
char[][] table = new char[10][5];What is the value of table.length?

A) 0
B) 5
C) 10
D) 15
سؤال
A Vector object can shrink during program execution.
سؤال
int[] numList = new int[50];for (int i = 0; i < 50; i++)
NumList[i]= 2 * i;
Num[10] = -20;
Num[30] = 8;
What is the index number of the last component in the array numList seen in the accompanying figure?

A) 0
B) 30
C) 49
D) 50
سؤال
char[][] table = new char[10][5];How many rows are in the array seen in the accompanying figure?

A) 0
B) 5
C) 10
D) 15
سؤال
Consider the following method definition.public static int strange(int[] list, int listSize, int item)
{
Int count = 0;
For (int j = 0; j (list[j]; == item)
Count++;
Return count;
}
Which of the following statements best describe the behavior of this method?

A) This method returns the number of values stored in list.
B) This method returns the sum of all the values of list.
C) This method returns the number of times item is stored in list.
D) This method can process an array of doubles.
سؤال
double[] as = new double[7];
Double[] bs;bs = as;How many objects are present after the code fragment in the accompanying figure is executed?

A) 1
B) 2
C) 7
D) 14
سؤال
Given the following method heading public static void mystery(int list[], int size)and the declarationint[] alpha = new int[75];Which of the following is a valid call to the method mystery?

A) mystery(alpha[75], 50);
B) mystery(alpha[], 50);
C) mystery(alpha, 40);
D) mystery(int[75], alpha)
سؤال
Given the method heading public static void strange(int a, int b)and the declarationint[] alpha = new int[20];
Int[] beta = new int[25];Which of the following is a valid call to the method strange?

A) strange(alpha[10], alpha[15]);
B) strange(alpha[5], beta);
C) strange(alpha[0], beta[25]);
D) strange(alpha, beta[20]);
سؤال
char[][] table = new char[10][5];How many dimensions are in the array seen in the accompanying figure?

A) 1
B) 2
C) 5
D) 10
سؤال
Only a fixed number of elements can be stored in a vector.
سؤال
Which of the following declares an array of int named beta?

A) int beta;
B) int[] beta;
C) new int beta[];
D) int beta = int[];
سؤال
Which method would you most likely use to find the location of an element in the vector?

A) lastElement
B) elementAt
C) indexOf
D) size
سؤال
Which method of the class vector would you use to remove an element at a specific location?

A) removeAllElements
B) removeElement
C) removeElementAt
D) removeLocation
سؤال
In which package is the class Vector located?

A) java.io
B) java.lang
C) java.util
D) java.text
سؤال
Which method would you most likely use to add an element to an end of a vector?

A) insertElementAt
B) addElement
C) copyInto
D) lastElement
سؤال
What does the following statement do?
Vector thisVector = new Vector();

A) It creates an empty vector to create a vector of Double objects.
B) It creates a vector with 10 elements to create a vector of Double objects.
C) This statement does not do anything.
D) It creates an array of Double objects.
سؤال
Which limitation of arrays does a vector overcome?

A) Arrays cannot increase in size; vectors can.
B) Arrays cannot be passed as parameters to methods; vectors can.
C) Arrays cannot be searched; vectors can.
D) There is a method that returns the length of a vector; there is no way to find the length of an array.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/46
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Arrays
1
Suppose list is a one-dimensional array, wherein each component is of the type int. The following for loop correctly finds the sum of the elements of list.int sum = 0; for (int num : list)
sum = sum + num;
True
2
In a method call statement, when passing an array as an actual parameter, you use only its name.
True
3
The statementint[] list = new int[15];creates list to be an array of 14 components because array index starts at 0.
False
4
Given the declarationdouble[] numList = new double[20];the statementnumList[12] = numList[5] + numList[7];updates the content of the thirteenth component of the array numList.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
5
Java stores two-dimensional arrays in a row order form in computer memory.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
6
A single array can hold components of many different data types.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
7
When an array object is instantiated, its components are initialized to their default values.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
8
If a method has both a variable length formal parameter and other types of formal parameters, then the variable length formal parameter must be the first formal parameter of the formal parameter list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
9
In row processing, a two-dimensional array is processed one row at a time.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
10
The array index can be any nonnegative integer less than the array size.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
11
Suppose that you have the following declaration.int[] alpha = new int[50];
int[][] beta = new int[10][5];In this declaration, the array alpha has more components than the array beta.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
12
Given the declaration int[] list = new int[50];the statementSystem.out.println(list[0] + "..." + list[49]);outputs all 50 components of the array list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
13
If an array index is less than or equal to zero, an InvalidIndexException exception is thrown.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
14
Arrays have a fixed number of elements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
15
When a boolean array object is instantiated, its components are initialized to false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
16
In column processing, a two-dimensional array is processed one column at a time.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
17
You can create an array of reference variables to manipulate objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
18
The base address of an array is the memory location of the first array component.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
19
Only one-dimensional arrays can be passed as parameters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
20
The following statement creates alpha to be a two-dimensional array of 35 components. int[][] alpha = new int[20][15];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
21
int[] list = {1, 3, 5, 7};(int i = 0; i < list.length; i++)
If (list[i] > 5)
System.out.println(i + " " + list[i]);Which indices are in bounds for the array list, given the declaration in the accompanying figure?

A) 0, 1, 2, 3
B) 1, 2, 3, 4
C) 1, 3, 5, 7
D) 0, 1, 3, 5
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
22
The statement dataType[][][] arrayName; would declare a two-dimensional array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
23
char[][] table = new char[10][5];How many columns are in the array seen in the accompanying figure?

A) 0
B) 5
C) 10
D) 15
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
24
char[][] table = new char[10][5];What is the value of table[2].length?

A) 0
B) 5
C) 10
D) 15
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
25
The method size in the class Vector returns the number of elements in the vector.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
26
Suppose you have the following declaration.double[] salesData = new double[500];Which of the following range is valid for the index of the array salesData.
(i) 0 through 500
(ii) 0 through 499

A) Only (i)
B) Only (ii)
C) Both are invalid
D) None of these
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
27
Which of the following is the array subscripting operator in Java?

A) .
B) {}
C) new
D) []
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
28
int[] numList = new int[50];for (int i = 0; i <50; i++)
NumList[i] = 2 * i;
Num[10] = -20;
Num[30] = 8;
How many components are in the array numList seen in the accompanying figure?

A) 0
B) 30
C) 49
D) 50
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
29
Vectors can be used to implement lists.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
30
char[][] table = new char[10][5];What is the value of table.length?

A) 0
B) 5
C) 10
D) 15
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
31
A Vector object can shrink during program execution.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
32
int[] numList = new int[50];for (int i = 0; i < 50; i++)
NumList[i]= 2 * i;
Num[10] = -20;
Num[30] = 8;
What is the index number of the last component in the array numList seen in the accompanying figure?

A) 0
B) 30
C) 49
D) 50
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
33
char[][] table = new char[10][5];How many rows are in the array seen in the accompanying figure?

A) 0
B) 5
C) 10
D) 15
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
34
Consider the following method definition.public static int strange(int[] list, int listSize, int item)
{
Int count = 0;
For (int j = 0; j (list[j]; == item)
Count++;
Return count;
}
Which of the following statements best describe the behavior of this method?

A) This method returns the number of values stored in list.
B) This method returns the sum of all the values of list.
C) This method returns the number of times item is stored in list.
D) This method can process an array of doubles.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
35
double[] as = new double[7];
Double[] bs;bs = as;How many objects are present after the code fragment in the accompanying figure is executed?

A) 1
B) 2
C) 7
D) 14
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
36
Given the following method heading public static void mystery(int list[], int size)and the declarationint[] alpha = new int[75];Which of the following is a valid call to the method mystery?

A) mystery(alpha[75], 50);
B) mystery(alpha[], 50);
C) mystery(alpha, 40);
D) mystery(int[75], alpha)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
37
Given the method heading public static void strange(int a, int b)and the declarationint[] alpha = new int[20];
Int[] beta = new int[25];Which of the following is a valid call to the method strange?

A) strange(alpha[10], alpha[15]);
B) strange(alpha[5], beta);
C) strange(alpha[0], beta[25]);
D) strange(alpha, beta[20]);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
38
char[][] table = new char[10][5];How many dimensions are in the array seen in the accompanying figure?

A) 1
B) 2
C) 5
D) 10
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
39
Only a fixed number of elements can be stored in a vector.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
40
Which of the following declares an array of int named beta?

A) int beta;
B) int[] beta;
C) new int beta[];
D) int beta = int[];
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
41
Which method would you most likely use to find the location of an element in the vector?

A) lastElement
B) elementAt
C) indexOf
D) size
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
42
Which method of the class vector would you use to remove an element at a specific location?

A) removeAllElements
B) removeElement
C) removeElementAt
D) removeLocation
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
43
In which package is the class Vector located?

A) java.io
B) java.lang
C) java.util
D) java.text
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
44
Which method would you most likely use to add an element to an end of a vector?

A) insertElementAt
B) addElement
C) copyInto
D) lastElement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
45
What does the following statement do?
Vector thisVector = new Vector();

A) It creates an empty vector to create a vector of Double objects.
B) It creates a vector with 10 elements to create a vector of Double objects.
C) This statement does not do anything.
D) It creates an array of Double objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
46
Which limitation of arrays does a vector overcome?

A) Arrays cannot increase in size; vectors can.
B) Arrays cannot be passed as parameters to methods; vectors can.
C) Arrays cannot be searched; vectors can.
D) There is a method that returns the length of a vector; there is no way to find the length of an array.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 46 في هذه المجموعة.