#Java % operator question

1 messages · Page 1 of 1 (latest)

modern minnow
#

I submitted the following:In Java, given two int variables num1>0 and num2>0, which of the following is/are true if num1 is
divisible by num2?

 I.  
 num1 % num2==0     
 II.
 num1==num2*(num1/num2)    
 III.
 num1==num1+(num1 % num2)

In Java, if num1 is divisible by num2, then statements I and II are true. Statement I is true because if num1 is divisible by num2, then the remainder of num1 divided by num2 will be 0, and the % operator in Java returns the remainder of a division operation. Statement II is also true because if num1 is divisible by num2, then num1 can be expressed as num2 multiplied by the quotient of num1 divided by num2.

Statement III is not true, because if num1 is divisible by num2, then the result of num1 plus the remainder of num1 divided by num2 will not be equal to num1. The remainder of num1 divided by num2 will be 0, so the result of num1 plus the remainder will be equal to num1, not equal to num1 itself.

Try again