## Expressions and Operators

Published:  June 7, 2007
By Richard G. Baldwin

File: Alice0160PracticeTest.htm

## Questions

1.  True or False:  Computer programs consist of expressions, which in turn consist of statements.

2.  True or False:  An expression is a specific combination of operators and operands, which evaluates to a particular result.  The operands can be variables, literals, or method calls that return a value.

3.  True or False:  A statement is a specific combination of expressions.

4.  True or False:  Operands are the action elements of a computer program.

They perform actions such as:

• Dividing one variable by another variable
• Comparing one variable to another variable, etc.

5.  True or False:  Operators operate on operands.  Stated differently, operands are the things that are operated on by operators.

6.  True or False:  An operator that operates on one operand is called a binary operator.

7.  True or False:  An operator that operates on two operands is called a binary operator.

8.  True or False:  According to the current jargon, binary operators in Alice use prefix notation.  This means that the operator appears between its operands.

9.  True or False:  In Alice, there is at least one unary operator that uses postfix notation.  This operator is the increment operator.

10.  True or False:  As a result of performing the specified action, an operator can be said to return a value (or evaluate to a value) of a given type.

11.  True or False:  Alice supports the operators in the following list:

```   +        Adds its operands
-        Subtracts the right operand
from the left operand
*        Multiplies the operands
/        Divides the left operand by
the right operand
%        Remainder of dividing the
left operand by the right
operand - modulus operator```

12.  True or False:  The arithmetic operators in Alice are exposed whenever you click the triangle immediately to the right of a component in an expression that can serve as the left operand for the operator.

13.  True or False:  Alice supports the equality operators shown in the following list:

```   ==       Returns true if operands are equal.
Otherwise returns false.
!=       Returns true if operands are not equal.
Otherwise returns false.```

14.  True or False:  The equality operators in the following list produce results of type Number.

```   ==       Returns true if operands are equal.
Otherwise returns false.
!=       Returns true if operands are not equal.
Otherwise returns 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.

False

True

True

False

True

True

False

True

False

True

False

True

True

False

### Explanation 1

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-