What is the result of running the following code?

int a = 7;
int b = 4;

System.out.println(-a % b);
System.out.println(a % -b);
System.out.println((-a % b) == (a % -b));    
Explanation
Operator % returns result with the sign of first operand. Sign of second operand is ignored.
Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback