224k views
3 votes
Assume the integer variable num has been assigned a valid value. What is the purpose of the following code segment?

if(num % 4 >0)
System.out.print(num);

1.)It prints num if it’s value is a multiple of 4

2.)It prints num if it’s value is not a multiple of 4

3.)It always prints the value of num

4.)It never prints the value of num

5.)An error occurs at compile time

1 Answer

4 votes

Answer:

2

Step-by-step explanation:

The num%4 operation returns the remainder, so only if num is not a multiple of 4, this value will be non-zero (it will be 1, 2 or 3).

User Cedrics
by
5.2k points