216k views
1 vote
Given the following variable declarations:

int x = 27;
int y = -1;
int z = 32;
boolean b = false;
What is the value of each of the following boolean expressions?
Sound F/X
!b b || true (x > y) && (y > z) (x == y) || (x <= z) !(x % 2 == 0) (x % 2 != 0) && b b && !b b || !b (x < y) == b !(x / 2 == 13) || b || (z * 3 == 96) (z < x) == false !((x > 0) && (y < 0))
Im working with java

User Gikas
by
7.3k points

1 Answer

1 vote

Answer:

!b = true

b || true = true

(x > y) && (y > z) = false

(x == y) || (x <= z) = true

!(x % 2 == 0) = true

(x % 2 != 0) && b = false

b && !b = false

b || !b = true

(x < y) == b = false

!(x / 2 == 13) || b || (z * 3 == 96) = true

(z < x) == false = true

!((x > 0) && (y < 0)) = true

Note that for the expressions involving arithmetic operations (such as x / 2 == 13), integer division is used, meaning that any remainder is truncated.

User Gangadhar Jannu
by
7.3k points