Chapter 31 JAVA Flashcards

1
Q

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.

A

A. Adding integer one to an integer variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A.

The expression on the right of the “=” is evaluated, “using” all the variables it contains.
The result of evaluation is assigned to the variable on the left of the “=”.
B.

All appropriate variables are incremented or decremented.
The result is assigned to the variable on the left of the “=”.
C.

All appropriate variables are incremented.
All appropriate variables are decremented.
D.

The arithmetic expression is evaluated and assigned to the variable on the left of the “=”.
Variables are auto-incremented or auto-decremented.

A

A.

The expression on the right of the “=” is evaluated, “using” all the variables it contains.
The result of evaluation is assigned to the variable on the left of the “=”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the meaning of variable++ ?
A. Add one to the variable.

B. Add one to the variable after its current value has been used.

C. Add one to the variable before using its value.
D. Double the value in the variable.

A

B. Add one to the variable after its current value has been used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

D. value: 2 count: 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

C. a: 9 b:9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

C. w is 25.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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;

A

A.

value = value + sum;
sum = sum + 1;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

wages _____ 2 ;
A. *=

B. -=

C. =/

D. /=

A

D. /=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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.

A

A. No — any program that uses them could be written without them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

D. value: 1 count: 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly