flipHorizontal
, flipVertical
, rotateLeft
, rotateRight
, shrink
, and enlarge
. Make sure that you can
open a picture and call these from the main
method.
yes
if the number is divisible by 173 or not.
yes
if the number is between 70 and 100, and no
if it is not.
x
from the
user and prints x
asterisks on the console.
x
, y
, and z
.
a
, b
, and c
are integer variables.
If there is something wrong with the statements below indicate what the problem is.
a) if a > b { c = b; } b) if (a > b) { c = b } c) if (a > b { c = b; System.out.println("a is bigger than b"); } else d) if (a > b) { c = b; }
!
is logical
negation. So !true
is the same as false and !false
is true. The precedence of &&
, ||, and !
is
that &&
has the highest precedence,
then ||
, and then !
. As an example consider the expression below:
int x = 5; int y = 7; System.out.println( x > y || !(3 > 4) && 5 <= 6 );
The first condition checked is if x > y
. This is false. Next we check if
!(3 > 4)
. This is true, 3 is not greater than 4.
Now we check if 5 is less than 6. This is true. Both sides of && are true so it evaluates to true.
Assuming that x
is 1
What is the output of the following:
int x = 1; System.out.println((true) && (3 > 4)); System.out.println(!(x > 0) && (x > 0)); System.out.println((x > 0) || (x < 0)); System.out.println(x != 0 || x == 0); System.out.println(x >= 0 || x < 0); System.out.println((x != 1) == !(x == 1));
int x = 3; int y = 2; int z = 0; if (x > 2) { if (y > 2) { z = x + y; System.out.println("z is " + z); } } else { System.out.println("x is " + x); }
x
is 3 and y
is 4?
x
is 2 and y
is 2?