Answer:
D. (int) (Math.random() * 4 + 1)
Explanation:
The first two options (A and B) will give a compiler error incompactible types since the Math.random() functions returns a double and val has been declared as an int. To overcome this, a type casting to integer is carried out. Option D (int) (Math.random() * 4 + 1) will return a value after been casted to an int of 1,2,3,4 which when this line val *= 2; is executed gives the expected output of 2,4,6 or 8.