Expressions
 

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:   

(c) Shilpa Sayura Foundation 2006-2017