Published: June 30, 2007
By Richard G. Baldwin
File: Alice0180PracticeTest.htm
1. After the execution of the code in Listing 16, what does idx contain?
Listing 1. 180-116.
public void main ( ) { Number[] myArray = [5,7,3,10,2]; Number x = 0 ; Number y = 0 ; Number idx = 0 ; for (int index=0;index < (myArray.length);index++){ x.set( value , ( myArray [ index ] ) ); if ( ( x > y ) ) { idx .set( value , index ); y .set( value , x ); } else { Do Nothing } } print( idx ); print( y ); } |
2. If score is an array containing 5 values, in the following order: 80, 75, 90, 60, 100, what is the content of score[1] ?
3. An array is a collection of values:
4. Which of the following would be used to store a list of 50 test scores?
5. In an array, we access the data value we are searching for by its
6. True or False: Arrays can be used as data structures or containers for data of any valid Alice type.
7. True or False: Whenever you need to use the data contained in an array in your program, you drag the array tile up from the bottom of the code edit pane and drop it into the edit pane.
8. True or False: If the declared type of an Alice array is Object, the individual objects that are stored in the array can include a variety of different kinds of objects such as penguins, monkeys, lemurs, ladybugs, kangaroos, the camera, the light, the ground, etc.
9. True or False: You can mix elements of type Boolean with type Number in an Alice array.
10. True or False: Each variable in an array is commonly called an element.
11. True or False: Each element in an array has a subscript or index that differentiates it from every other element in the array. (Some people call it a subscript while others call it an index.)
12. True or False: An array index is negative integer that indicates the position of a particular element relative to the first element in the array. The first element in the array always has an index value of 0.
13. True or False: It is not necessary to declare an array before you can use it. Arrays are created automatically by the Alice runtime system when needed.
14. True or False: You specify the number of elements (the size) of an array when you declare it. Once created, the size of an array cannot be changed at runtime.
15. True or False: If the size of the array is N, the index values for the elements in the array always extend from 0 to N inclusive
16. True or False: You access an individual element in an array by:
17. True or False: If you attempt to access an array element at an index value that is equal to or larger than the size of the array, the program will abort with an error at runtime. Similarly, if you attempt to access an array element using a negative index, the program will abort with an error at runtime.
18. True or False: Once an array element is populated, it is impossible to remove the contents of the element. If you don't want those contents to be there, you must overwrite those contents with something else.
Copyright 2007, Richard G. Baldwin.
Faculty and staff of public and private non-profit educational institutions are
granted a license to reproduce and to use this material for purposes consistent
with the teaching process. This license does not extend to commercial
ventures. Otherwise, reproduction in whole or in part in any form or medium
without express written permission from Richard Baldwin is prohibited.
The following image is the splash screen from Alice 2.0, and is the property of the developers of Alice at Carnegie Mellon.
Copyright 2007, Richard G. Baldwin. Faculty and staff of public and private non-profit educational institutions are granted a license to reproduce and to use this material for purposes consistent with the teaching process. This license does not extend to commercial ventures. Otherwise, reproduction in whole or in part in any form or medium without express written permission from Richard Baldwin is prohibited.
The following image is the splash screen from Alice 2.0, and is the property of the developers of Alice at Carnegie Mellon.
-end-