Casting and Range of Variables FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

Fill in each value in the table. Then explain why the second and third results differ.

Expression Value
(int) 4.99 ?
(double) 14 / 5 ?
(int) (14 / 5) ?

Question 2 of 5

Write the usual expression that rounds a nonnegative double to the nearest int by adding 0.5 and casting. Evaluate that expression for 3.49 and for 3.50.

Question 3 of 5

Trace this update. Give the mathematical result of subtracting 3, the Java int result, and explain why they differ.

int debt = Integer.MIN_VALUE + 1;
debt -= 3;

Question 4 of 5

A loading dock estimates half a shipment. The intended value of half is 1400000000, which fits in an int. Explain why this code does not store that value, state the intended mathematical result, and write a corrected expression that avoids the overflowing product.

int packs = 70000;
int weight = 40000;
int half = packs * weight / 2;

Question 5 of 5

A phone stores battery voltage as double volts = 3.7;. Explain why 3.7 may not be stored exactly. Name this kind of error. Give an int millivolt amount for 3.70 V that remains exact if all values and intermediate totals fit in an int.