in java What is the result of the following expression? 25 / 4 + 4 * 10 % 3?

25/4+4*10%3
6+4*1
6+1
7

The precedence is
/ , * , %

going left to right
25 / 4 = 6
4 * 10 = 40
40 % 3 = 1
6 + 1 = 7;
With the parenthesis it would look like this
(25 / 4 ) + ( (4 * 10) % 3)
modulo operator is integer only, no fraction

Here’s a crazy idea: Write one line of Java code and find out.

Answer 6

the answer would be 7..

Answer 7

1.25, the expression will be evaluated left to right.

Also Read :   What is the tension in the rope of the figure? (figure 1)

Leave a Comment