Given:



int i, j = 0;
i = (3 * 2 + 4 + 5);
j = (3 * ((2 + 4) + 5));
System.out.println("i:" + i + "\nj:" + j);

What is the result?

A.

i:16
j:33

B.

i.15
j:33

C.

i:33
j:23

D.

i:15
j:23

題解

Java的算式遵循「先乘除,後加減」和「括號內先計算」的規則,因此此題的運算過程如下:

i = (3 * 2 + 4 + 5) = (6 + 4 + 5) = (10 + 5) = 15
j = (3 * ((2 + 4) + 5)) = (3 * (6 + 5)) = (3 * 11) = 33