What output will be produced by the following Java program? public class Test { public static void main(String[] args) { float f = (1 / 4) * 10; int i = Math.round(f); System.out.println(i); } }
Explanation
In the expression (1 / 4) * 10, integer division occurs first, so 1 / 4 evaluates to 0. Multiplying 0 by 10 results in 0.0f for the float variable f. When Math.round(0.0f) is called, it returns 0, which is printed. Therefore, the output is 0.