Assume that x, y and z are all ints equal to 50, 20 and 6 respectively. What is the result of x / y / z?


Assume that x, y and z are all ints equal to 50, 20 and 6 respectively. What is the result of x / y / z?


a) 0

b) 12

c) 16

d) A syntax error as this is syntactically invalid

e) A run-time error because this is a division by 0

Answer: a. Explanation: This division is performed left to right, so first 50 / 20 is performed. Since 50 and 20 are ints, this results in 2. Next, 2 / 6 is performed which is 0. Notice that if the division were performed right to left, the evaluation would instead be 50 / (20 / 6) = 50 / 3 = 16.