Introduction to Java Programming, Eighth Edition, Y. Daniel Liang
Chapter 2 Elementary Programming
11
Which of the following assignment statements is incorrect?
A.
i = j = k = 1;
B.
i = 1; j = 1; k = 1;
C.
i = 1 = j = 1 = k = 1;
D.
i == j == k == 1;
Section 2.7 Constants
12
To declare a constant MAX_LENGTH inside a method with value 99.98, you write
A.
final MAX_LENGTH = 99.98;
B.
final float MAX_LENGTH = 99.98;
C.
double MAX_LENGTH = 99.98;
D.
final double MAX_LENGTH = 99.98;
13
Which of the following is a constant, according to Java naming conventions?
A.
MAX_VALUE
B.
Test
C.
read
D.
ReadInt
E.
COUNT
14
To improve readability and maintainability, you should declare _________ instead of using literal values such as 3.14159.
A.
variables
B.
methods
C.
constants
D.
classes
Sections 2.8-2.9
15
Which of these data types requires the most amount of memory?
A.
long
B.
int
C.
short
D.
byte
16
To declare an int variable number with initial value 2, you write
A.
int number = 2L;
B.
int number = 2l;
C.
int number = 2;
D.
int number = 2.0;
17
What is the result of 45 / 4?
A.
10
B.
11
C.
11.25
D.
12
18
Which of the following expressions will yield 0.5?
A.
1 / 2
B.
1.0 / 2
C.
(double) (1 / 2)
D.
(double) 1 / 2
E.
1 / 2.0
19
Which of the following expression results in a value 1?
A.
2 % 1
B.
15 % 4
C.
25 % 5
D.
37 % 6
20
25 % 1 is _____
A.
1
B.
2
C.
3
D.
4
E.
0
Next Page >