Question: 11. An array always contains (1 point) objects primitive types either objects or primitive types a mix of objects and primitive types different kinds of

11.

An array always contains (1 point)

objects

primitive types

either objects or primitive types

a mix of objects and primitive types

different kinds of objects

12.

Polymorphism occurs at (1 point)

compile time

debug time

early binding time

run time

none of the above

13.

What is the maximum number of locations a binary search algorithm will have to examine when looking for a particular value in a sorted array of 500 elements? (2 points)

1

2

7

9

500

14.

What is the maximum number of locations a sequential search algorithm will have to examine when looking for a particular value in an array of 100 elements? (1 point)

1

12

25

50

100

15.

Which of the following sorting algorithms is described by this text? "Split the array in two parts. Take each part, and split it into two parts. Repeat this process until each part has only two items. Check the order of the two items and swap if necessary. Then, take the sorted part and combine it with an adjacent part, sorting as you combine. Repeat until all parts have been combined." (2 points)

Insertion sort

Merge sort

Heap sort

Quick sort

Selection sort

16.

Which of the following sorting algorithms is written recursively? (1 point)

Sequential

Binary

Selection

Insertion

Merge

17.

The following method is intended to remove all values from the ArrayList < Integer > aList that have the same value as val; however, this method does NOT work correctly. public void removeValue(ArrayList < Integer > aList, int val) { int i; for(i = 0; i < aList.size(); i++) { if(aList.get(i) == val) { aList.remove(i); } } } If aList initially contains 2 3 4 3 3 4 4 5 4 3 2 1 and val is equal to 4, then aList should contain 2 3 3 3 5 3 2 1 after removeValue is invoked. What does aList actually contain after removeValue is invoked? (2 points)

2 3 3 3 5 3 2 1

2 4 3 4 5 4 2 1

2 3 3 3 4 5 3 2 1

2 4 3 4 4 5 3 2 1

2 3 3 4 4 5 4 3 2 1

18.

Consider the following method: public int mystery(int n) { if(n > 6) { return 1 + mystery(n - 1); } return n % 3; } What is the value of mystery(10)? (2 points)

4

6

8

9

10

19.

Assume a two-dimensional array is declared as follows: int arr[][] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; Which of these statements are true? (2 points)

  1. arr.length is 3
  2. arr[0].length is 3
  3. arr[2][3] is 12

I only

I and II only

I and III only

III only

I, II, and III

20.

What is stored in the array arr after the following code executes? (2 points) int[ ] arr = {17, 34, 43, 71}; int i = 0; while(i < arr.length) { if((arr[i] % 2) == 1) { arr[i] = arr[i] % 3; } else { arr[i] = arr[i] / 3; } i++; }

{1, 11, 2, 10}

{2, 10, 11, 1}

{2, 11, 1, 2}

{2, 11, 1, 10}

An ArrayIndexOutOfBoundsException occurs.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!