#
Question :
11)Which of the following lists of numbers would accurately show : 2015387

11)Which of the following lists of numbers would accurately show the array after the fourth pass of the Selection Sort algorithm?

a)9, 4, 12, 2, 6, 8, 18

b)2, 4, 6, 9, 12, 8, 18

c)2, 4, 6, 8, 9, 12, 18

d)2, 4, 6, 9, 8, 12, 18

e)2, 4, 6, 8, 12, 9, 18

12)How many passes will it take in all for Selection Sort to sort this array?

a)2

b)4

c)5

d)6

e)7

13) What does the following code do?

a)adds 1 to the number of bars sold by child value1 and child value2

b)adds 1 to the number of bars sold by child value1

c)adds value1 to the number of bars sold by child value2

d)adds value2 to the number of bars sold by child value1

e)inputs a new value for the number of bars sold by both child value1 and child value2

14) Which of the following code could be used to compute the total number of bars sold by the children?

a)for(int j=0; j<12; j++) sum+= candy[j];

b)for(int j=0; j<12; j++) candy[j] = sum;

c)for(int j=0; j<12; j++) sum = candy[j];

d)for(int j=0; j<12; j++) sum += [j];

e)for(int j=0; j<12; j++) [j] += sum;

15)What does the following method do?

public int question15( )

{

int value1 = 0;

int value2 = 0;

for(int j=0; j<12; j++)

if(candy[j] > value1)

{

value1 = candy[j];

value2 = j;

}

return value2;

}

a)It returns the total number of candy bars sold

b)It returns the total number of children who sold 0 candy bars

c)It returns the total number of children who sold more than 0 candy bars

d)It returns the number of candy bars sold by the child who sold the most candy bars

e)It returns the index of the child who sold the most candy bars

16)We compare sorting algorithms by examining

a)the number of instructions executed by the sorting algorithm

b)the number of instructions in the algorithm itself (its length)

c)the types of loops used in the sorting algorithm

d)the amount of memory space required by the algorithm

e)whether the resulting array is completely sorted or only partially sorted

17)Both the Insertion Sort and the Selection Sort algorithms have efficiencies on the order of ____ where n is the number of values in the array being sorted.

a)n

b)n * log n

c)n^{2}

d)n^{3}

e)Insertion sort has an efficiency of n and Selection Sort has an efficiency of n^{2}

18)Consider the array declaration and instantiation: int[ ] arr = new int[5]; Which of the following is true about arr?

a)It stores 5 elements with legal indices between 1 and 5

b)It stores 5 elements with legal indices between 0 and 4

c)It stores 4 elements with legal indices between 1 and 4

d)It stores 6 elements with legal indices between 0 and 5

e)It stores 5 elements with legal indices between 0 and 5

19)If an int array is passed as a parameter to a method, which of the following would define the parameter list for the method header?

a)(int[ ])

b)(int a[ ])

c)(int[ ] a)

d)(int a)

e)(a[ ])

20)If int[ ] x = new int[15]; and the statement x[-1] = 0; is executed, then which of the following Exceptions is thrown?

a)IndexOutOfBoundsException

b)ArrayIndexOutOfBoundsException

c)NegativeArraySizeException

d)NullPointerException

e)ArithmeticException