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

NetherCraft 0

5 Answers

  • 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.

  • the answer would be 7..

  • 1.25, the expression will be evaluated left to right.

Also Check This  largest / biggest serif font?

Leave a Reply

Your email address will not be published. Required fields are marked *