Unit 1 Quiz Flashcards

1
Q

An array called myNums holds the following numbers. What is the value of element myNums[3]?

2

3

4

5

6

A

5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the proper way to declare an array to hold movie titles?

A

String[] movieTitles;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

For a sequential search to work on an array, the array must be sorted? True of False

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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]);

A

-2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A For-Each loop is a handy way to iterate through an array.

True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

2

3

4

5

6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

For a binary search to work on an array, the array must be sorted.

True or False

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

An Array element is accessed by its:

A

Index

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which sorting method is more efficient?

A

API sort method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly