Published: June 25, 2007
By Richard G. Baldwin
File: Alice0170PracticeTest.htm
1. What is the value of C after the code in Listing 170-110 is executed?
Listing 170-110.
public void main ( ) { Number A = 5 ; Number B = 5 ; Number C = 0 ; if ( ( A >= B ) ) { if ( ( A > B ) ) { C .set( value , 1 ); } else { C .set( value , 2 ); } } else { C .set( value , 3 ); } print( C ); } |
2. Given the code in Listing 170-111, what is the range of the value of the variable result that is displayed after the while loop has finished executing?
Listing 170-111.
public void main ( ) { Number number = 0 ; Number result = 0 ; number.set(value,(NumberDialog(question=Enter num))); while ( ( ( ( number < 0 ) || ( number > 100 ) ) ) ) { number.set(value,(NumberDialog(question=Enter num)))); } result .set( value , number ); print( result ); } |
3. Assume x and y are Boolean variables. If x has the value true, and y has the value false, which of the following expressions evaluates to true?
4. True or False: The following operators with the symbols given are supported by Alice:
5. True or False: Operators 1 through 4 in the following list are relational operators. Operators 5 through 7 in the list are combinational logic operators.
6. True or False: Assume that A and B are numeric variables or expressions that evaluate to numeric values. The expression (A < B) will evaluate to true if A is algebraically less than B, and will evaluate to false otherwise.
7. True or False: Assume that A and B are numeric variables or expressions that evaluate to numeric values. The expression (A > B) will evaluate to true if A is algebraically less than B, and will evaluate to false otherwise.
8. True or False: Assume that A and B are numeric variables or expressions that evaluate to numeric values. The expression (A <= B) will evaluate to true if A is algebraically less than or is equal to B, and will evaluate to false otherwise.
9. True or False: Assume that A and B are numeric variables or expressions that evaluate to numeric values. The expression (A >= B) will evaluate to true if A is algebraically less than or is equal to B, and will evaluate to false otherwise.
10. True or False: Assume that A and B are numeric variables or expressions that evaluate to numeric values. The expression (A == B) will evaluate to true if A is equal to B, and will evaluate to false otherwise.
11. True or False: Assume that A and B are numeric variables or expressions that evaluate to numeric values. The expression (A != B) will evaluate to true if A is equal to B, and will evaluate to false otherwise.
12. True or False: Assume that X and Y are Boolean variables or expressions that evaluate to the Boolean values of true and false. The expression (X && Y) will evaluate to true if both X and Y are true, and will evaluate to false otherwise.
13. True or False: Assume that X and Y are Boolean variables or expressions that evaluate to the Boolean values of true and false. The expression (X || Y) will evaluate to true if both X and Y are true, and will evaluate to false otherwise.
14. True or False: If X is true, !X evaluates to false.
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-