Math Class FRQ Practice

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

Question 1 of 5

A survey program needs nonnegative sizes.

(a) Write an expression that stores Math.abs(-27) in int rise. (b) Write an expression that stores the double absolute value of -2.5 in double gust. (c) Explain why those two calls have different result types.

Question 2 of 5

(a) State the value and type of Math.sqrt(49). (b) State the value and type of Math.pow(2, 5). (c) State the value of int n = (int) Math.pow(2, 5); and explain the cast.

Question 3 of 5

(a) State the range of Math.random() as a double interval, including which endpoint is excluded. (b) State the inclusive integer range of (int)(Math.random() * 5). (c) Explain why 5 cannot be produced by that integer expression.

Question 4 of 5

A marker ID must be an int from 10 through 20 inclusive.

(a) Write a Java expression using Math.random that produces that range. (b) Show the count of integers in 10 through 20. (c) Explain the role of the cast versus the added shift.

Question 5 of 5

A tester substitutes 0.0 and 0.75 for Math.random().

int a = (int) (0.0 * 6);
int b = (int) (0.75 * 6);

(a) State a and b. (b) Explain which endpoints of 0 through 5 those samples illustrate. (c) Explain whether 0.999... * 6 can equal 6 before casting.