on Expressions

This is a practice quiz. The results are not recorded anywhere and do not affect your grade. The questions on this quiz might not appear in any quiz or test that does count toward your grade.

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.


1. Which one of the following is NOT a correct arithmetic expression?

a. alpha
b. (alpha / momentum) - 12.4
c. alpha ( / momentum - 12.4 )
d. ((alpha / momentum) - 12.4)

2. What is an operand?

a. Another name for number.
b. Another name for integer.
c. One of the arithmetic symbols like *, +, -, and /.
d. A value that is acted upon by an operator.

3. Assume the following declarations:

short  a=12 ;
int    b=33 ;

float  x = 2.3;
double y = 3.14;

Which one of the following expressions will NOT be evaluated using double precision floating point?

a. a + x
b. 1.5 + 8.6
c. a + b
d. x / y

4. What does the following program output?

class question4
{
  public static void main ( String[] args )
  {
    int totalCost = 6;    
    int items     = 12;
    System.out.println("cost per item: " + totalCost/items );
  }
}
a. cost per item: .5
b. cost per item: 0
c. cost per item: 1
d. cost per item: +6/12

5. What is the result of evaluating the following expression?

( 1/2 + 3.5) * 2.0
a. 8.0
b. 8
c. 7.0
d. 0

6. What is the result of evaluating the following expression?

-32 / 6
a. -2
b. -5
c. -5.3333
d. +6

7. What is an expression?

a. The same thing as a statement.
b. An expression is a list of statements that make up a program
c. An expression is a combination of literals, operators, variables, and parentheses used to calculate a value.
d. An expression is a number expressed in digits.

8. Given the following expression:

(a - x)/(13 - z)

Which of the following is NOT a subexpression?

a. (a - x)
b. (13 - z)
c. a - x
d. x ) / (13

9. What is the value of

-32 % 6
a. 5
b. -5
c. 2
d. -2

10. Which of the following declarations works for the constant pi (assume that the numerical value is correct)?

a. final pi = 3.14159265358979 ;
b. final double pi = 3.14159265358979 ;
c. constant double pi = 3.14159265358979 ;
d. double pi = 3.14159265358979 ;

The number you got right:       Percent Correct:       Letter Grade:   

(If you have just returned here from another page, or re-loaded this page, you will need to click again on each of your choices for the grading program to work.)


Click here to go back to the main menu.