Java student - confusing quiz questions

Hello Java World! I am hoping that someone can clear up some questions for me. I recently took a quiz and I don't understand why a few of my answers were counted wrong. In the following problem:

Complete this coding to print exactly 3 numbers on every line:

Code :

for (int k = 5; k < 65; k++)
if ( ________________ == 1)
System.out.println (" " + k);
else
System.out.print (" " + k);

Why is the answer k%3?

In the following problem:

if (x == 5 || y > 2) is fully equivalent to if ( ! ( ________________ ) )

Why is the answer x != 5 && y <= 2

In the following problem:

Complete this if-statement (you may use else) to assign to x the smaller of y and z:

if (y < z) ________________ ;

Why is the answer x = y; else x = z

Also, can you put the else statement and the other on the same line?

I'm sorry if these questions seem basic but I am just starting out and I want to make sure I understand completely before moving on. Thank you so much for taking the time to help!

Re: Java student - confusing quiz questions

Quote:

Originally Posted by

**Techstudent**
Complete this coding to print exactly 3 numbers on every line:

Code :

for (int k = 5; k < 65; k++)
if ( ________________ == 1)
System.out.println (" " + k);
else
System.out.print (" " + k);

Why is the answer k%3?

Do you know what is the % operator?

Quote:

Originally Posted by

**Techstudent**
In the following problem:

if (x == 5 || y > 2) is fully equivalent to if ( ! ( ________________ ) )

Why is the answer x != 5 && y <= 2

Do you know De Morgan's laws? (hint: search on Wikipedia)

This is inherent to boolean algebra.

Quote:

Originally Posted by

**Techstudent**
In the following problem:

Complete this if-statement (you may use else) to assign to x the smaller of y and z:

if (y < z) ________________ ;

Why is the answer x = y; else x = z

If y is lower than z, what is the smaller? And otherwise?