Variables and Assignment
 

1. Which one of the following is a reserved word?

A. apple
B. 7up
C. grandTotal
D. boolean

2. Which one of the following is NOT a correct variable name?

A. 2bad
B. zero
C. theLastValueButOne
D. year2000

3. Which one of the following declarations is NOT correct?

A. double duty;
B. float loan;
C. boolean value = 12;
D. int start = 34, end = 99;

4. What does the following program output?

class question4
{
  public static void main ( String[] args )
  {
    int unitCost = 8;    
    int items    = 5;
    System.out.println("total cost: " + (unitCost * items) );
  }
}

A. total cost: + 40
B. total cost: 8*5
C. total cost: 40
D. "total cost: " 40

5. Which of the following shows the syntax of an assignment statement?

A. variableName = expression;
B. expression = expression;
C. expression = variableName;
D. dataType = variableName;

6. What are the two steps that take place when an assignment statement is executed?

A. (i) Evaluate the Expression, and (ii) Store the value in the variable.
B. (i) Store the value in the variable, and (ii) Evaluate the Expression.
C. (i) Reserve memory , and (ii) fill it with a number.
D. (i) Evaluate the variable, and (ii) store the results.

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. Which one of the following expressions is NOT correct?

A. 5 + 4
B. (5 * 4)/2
C. (-12 + (13 + 7)/2 ) * 4
D. -12 + (13 + 7)/2 ) * 4

9. Which of the following expressions is incorrect?

A. (34 - 86) / 3
B. (34 - 86) / -3
C. 34 - 86) / (23 - 3 )
D. ( (34 - 86) / (23 + 3 ) )

10. What is the value of the following expression:

(2 - 6) / 2 + 9

A. 7
B. 8
C. 9
D. 10

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

(c) Shilpa Sayura Foundation 2006-2017