created: 11/24/99; revised: 10/04/03


on Various Operators

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. What is the most common operation performed by a program?

A.    Adding integer one to an integer variable.
B.    Floating point division.
C.    Object construction.
D.    Internet access.

2. What two steps are performed when an assignment statement is executed?

A.   
  1. The expression on the right of the "=" is evaluated, "using" all the variables it contains.
  2. The result of evaluation is assigned to the variable on the left of the "=".
B.   
  1. All appropriate variables are incremented or decremented.
  2. The result is assigned to the variable on the left of the "=".
C.   
  1. All appropriate variables are incremented.
  2. All appropriate variables are decremented.
D.   
  1. The arithmetic expression is evaluated and assigned to the variable on the left of the "=".
  2. Variables are auto-incremented or auto-decremented.

3. What is the meaning of variable++   ?

a.    Add one to the variable.
E.    Add one to the variable after its current value has been used.
F.    Add one to the variable before using its value.
d.    Double the value in the variable.

3. What does the following program output to the monitor:

int value = 0;
int count = 1;

value = count++ ;

System.out.println("value: "+ value " + count: " + count ); 

A.    value: 0 count: 0
B.    value: 0 count: 1
C.    value: 1 count: 1
D.    value: 1 count: 2

4. What does the following program output to the monitor:

int value = 0;
int count = 1;

value = ++count ;  /* note change from previous */

System.out.println("value: "+ value " + count: " + count ); 

A.    value: 0 count: 1
B.    value: 1 count: 1
C.    value: 1 count: 2
D.    value: 2 count: 2

5. What is the output of the following:

int a = 0;
int b = 10;

a = --b ;

System.out.println("a: " + a + "  b: " + b ); 

A.    a: 9 b:11
B.    a: 10 b: 9
C.    a: 9 b:9
D.    a: 0 b:9

6. What is the output of the following program:

double w = 12.5 ;
w *= 2 ;

System.out.println( " w is " + w  ); 

A.    w is 12.5
B.    w is 13.5
C.    w is 25.0
D.    w is 2

7. Which of the answers does the same thing as the following:

value += sum++ ;

A.   
value = value + sum;
sum = sum + 1;
B.   
sum = sum + 1;
value = value + sum;
C.   
value = value + sum;
d.   
value = value + ++sum;

8. Fill in the blank so that wages is divided by two.

wages ____________ 2 ;

A.    *=
B.    -=
C.    =/
D.    /=

9. Are the auto-increment and auto-decrement operators (++ and -- ) an essential part of the Java language?

A.    No---any program that uses them could be written without them.
B.    No---they are not fundamental, but some programs could not be written without them.
C.    Yes---some programs can't be written unless these operators are available.
D.    Yes---because adding or subtracting one can't be done without them.

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


Click here

If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.