Download presentation
Presentation is loading. Please wait.
Published byRalf Webb Modified over 9 years ago
1
PreAP Computer Science Quiz 11.03- 05 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.
2
Title the quiz as shown below The quiz starts in ONE minute. Name Period Date Quiz 11.03-05 1. 9. 2. 10. 3. 11. 4. 12. 5. 13. 6. 14. 7. 15. 8. 16. EC.
3
Question 01 What data type is the array index? (a)int (b)double (c)char (d)any simple data type
4
Question 02 What is the index value of the first array element? (a)a (b)1 (c)0 (d)Any specified integer value
5
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
6
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
7
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
8
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
9
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
10
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)0 1 2 3 4 5 6 7 8 9 (B)0 1 2 3 4 5 6 7 8 (C)1 2 3 4 5 6 7 8 (D)2 3 4 5 6 7 8 9
11
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)0 1 2 3 4 5 6 7 8 9 (B)0 1 2 3 4 5 6 7 8 (C)1 2 3 4 5 6 7 8 (D)2 3 4 5 6 7 8 9
12
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));
13
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 [0..1000] range
14
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
15
Question 13 Which Arrays method assigns the same value to every array element? (a)assign (b)alter (c)fill (d)place
16
Question 14 Which Arrays method searches for a specified array value and then returns the index? (a)binarySearch (b)returnIndex (c)searchValue (d)linearSearch
17
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.
18
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)22 33 11 55 44 (B)[22, 33, 11, 55, 44] (C)11 22 33 44 55 (D)[11, 22, 33, 44, 55] (E)There is no output without a loop structure.
19
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.