Unit 1 Quiz Flashcards
An array called myNums holds the following numbers. What is the value of element myNums[3]?
2
3
4
5
6
5
What is the proper way to declare an array to hold movie titles?
String[] movieTitles;
For a sequential search to work on an array, the array must be sorted? True of False
False
What is the output of the below code when using the array declaration shown:
int[][] x = {{8, -2, 4}, {1, 0, 5} };
System.out.println(x[0][1]);
-2
A For-Each loop is a handy way to iterate through an array.
True or False
True
What is the output from the printline after the following code:
int[] myNums = {2, 3, 4, 5, 6};
for (int n : myNums)
System.out.println(n);
2
3
4
5
6
For a binary search to work on an array, the array must be sorted.
True or False
True
An Array element is accessed by its:
Index
Which sorting method is more efficient?
API sort method
What is the output of the below line of code for an Array of numbers called myNums. The array contains:
2
3
4
5
6
System.out.println(myNums.length);
5