Which of the following data types is designed to store true/false values?
a. boolean
b. char
c. byte
d. A and B only
e. all of the above - Answers a. boolean
Which of the following statements uses a compound assignment operator?
a. index = index + 1;
b. index++;
c. index += 1;
d. both B and C
e. all of the above - Answers c. index += 1;
What is the value of c after the following code is executed?
int a = 5;
int b = 2;
int c = 10;
c = c + b * 5 - c / a;
a.18
b.10
c.58
d.55 - Answers a. 18
Which of the following data types is designed store whole numbers (no decimal positions)?
a. int
b. long
c. short
d. A and B only
e. all of the above - Answers e.
all of the above
After the following statements execute, what is the value of the the variable named tax?
double tax = 12.398;
tax = (double) Math.round(tax * 100) / 100;
a.12.39
b.12.40
c.1239.20
d.12 - Answers b.
12.40
Based on the naming recommendations in the book, which of the following is a good identifier for a
constant that will be used to hold a base shipping charge?
a.BaseShippingCharge
b.BASE-SHIPPING-CHARGE
c.BASESHIPPINGCHARGE
d.baseShippingCharge
e.BASE_SHIPPING_CHARGE - Answers e.
BASE_SHIPPING_CHARGE
If an integer value is too big for the int type, you should store it in the ____________ type.
a. string
b. long
c. double
d. float - Answers b.
long
What is the range of values that x can hold after this statement is executed?
double x = Math.random() * 10 + 100;