Multiple Choice
How do we call the
number >= 15
part in the if statement below?if (number >= 15) { System.out.println("Sorry, number is too large"); }
When you wish to check if an integral number differs from another integral number, then you need to use the ... operator.
How many
if else
clauses can we add to an if statement?What is the output of the following code snippet?
boolean x = false; boolean y = true; int z = 13; if (z > 10 || (x != true && y == false)) { System.out.println("Sorry, access denied"); } else { System.out.println("Nice one, access granted"); }
What is the value of
a
that will be printed to the terminal?int a = 15; if (true || (a > 100)) { a = a + 2; } System.out.println("a = " + a);
Which of the operators below is a comparison operator?
What is the resulting value in
E
?boolean A = true; boolean B = false; boolean C = true; boolean D = (A && B ) || C; boolean E = (!D) || (!A);
What condition is required (in place of
<condition_here>
) to get a list of all even numbers between 0 (inclusive) and 100 (exclusive)?System.out.print("All even numbers between 0 and 100: "); for (int i = 0; i < 100; i++) { if (<condition_here>) { System.out.print(i + " "); } }
Last updated