PreAP Computer Science Quiz Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 30 – 60 seconds per question.
Title the quiz as shown below The quiz starts in ONE minute. Name Period Date Quiz EC.
Question 01 What data type is the array index? (a)int (b)double (c)char (d)any simple data type
Question 02 What is the index value of the first array element? (a)a (b)1 (c)0 (d)Any specified integer value
Question 03 The following array declaration: int list[ ]; list = new int[10]; is the same as which declaration? (a)int list[ ] = new list[10]; (b)int list[ ] = new int[10]; (c)New int = list[10]; (d)All of the above
Question 04 What is the output of this program segment? int list[] = {100,200,300,400,500,600,700,800}; System.out.println(list[1]); (a)100 (b)200 (c)700 (d)800 (e)Error
Question 05 What is the output of this program segment? int list[] = {100,200,300,400,500,600,700,800}; System.out.println(list[0]); (a)100 (b)200 (c)700 (d)800 (e)Error
Question 06 What is the output of this program segment? int list[] = {100,200,300,400,500,600,700,800}; System.out.println(list[7]); (a)100 (b)200 (c)700 (d)800 (e)Error
Question 07 What is the output of this program segment? int list[] = {100,200,300,400,500,600,700,800}; System.out.println(list[8]); (a)100 (b)200 (c)700 (d)800 (e)Error
Question 08 What is the output of this program segment? int list[] = new int[10]; for (int index = 0; index < list.length; index++) list[index] = index; for (int index = 0; index < list.length; index++) System.out.print(list[index] + " "); (A) (B) (C) (D)
Question 09 What is the output of this program segment? int list[] = new int[10]; for (int index = 0; index < 10; index++) list[index] = index + 1; for (int index = 1; index <= 8; index++) System.out.print(list[index] + " "); (A) (B) (C) (D)
Question 10 Which of the following is a correct statement to display all the values of the following array? int list[ ] = {1,2,3,4,5,6,7,8,9}; (a)for (int k = 1; k <= 9; k++) System.out.println(list[k]); (b)for (int k = 1; k < 9; k++) System.out.println(list[k]); (c)for (int k = 0; k < 9; k++) System.out.println(list[k]); (d)for (int k = 0; k <= 9; k++) System.out.println(list(k));
Question 11 What type of values are stored in list by the following program segment? int list[ ] = new int[20]; for (int k = 0; k < 20; k++) list[k] = Expo.random(0,1000); (A) A set of integers in the [1..20] range (B) A set of integers in the [0..19] range (C) A set of integers in the [0..999] range (D) A set of integers in the [ ] range
Question 12 Which Arrays method allows you to display the contents of an array with a single statement, like System.out.print or System.out.println ? (a)show (b)toString (c)display (d)output
Question 13 Which Arrays method assigns the same value to every array element? (a)assign (b)alter (c)fill (d)place
Question 14 Which Arrays method searches for a specified array value and then returns the index? (a)binarySearch (b)returnIndex (c)searchValue (d)linearSearch
Question 15 When will the binarySearch method of the Arrays class not perform correctly? (a)When a for loop is used. (b)When a while loop is used. (c)When the array elements are sorted. (d)When the array elements are not sorted.
Question 16 What is the output of this program segment? int list[ ] = {22,33,11,55,44}; Arrays.sort(list); System.out.println(Arrays.toString(list)); (A) (B)[22, 33, 11, 55, 44] (C) (D)[11, 22, 33, 44, 55] (E)There is no output without a loop structure.
Extra Credit What is the output of this program segment? int numbers[ ] = {10,11,12,13,14,15,16,17,18,19,20}; int rand = Expo.random(0,6); System.out.println(numbers[rand]); (A) An integer in the [0..6] range (B) An integer in the [10..20] range (C) An integer in the [0..10] range (D) An integer in the [10..16] range (E) An integer in the [10..15] range